0

I want to read a file using a bash script and I get a prefix of squares □□. My question is why I get this squares and how I can remove them. Sry I am new to bash scripts. And thank you all for the help.

I have a file named RELNOTES.md

# Changelog

All notable changes to this project will be documented in this file.

## [1.0.20] - 2022-07-23

### Bug Fixes

- Release job description

### Documentation

- Add docs for changelog using git cliff

### Features

- Git cliff setup

<!-- generated by git-cliff -->

And a bash script to read the file

#!/bin/sh

echo "$(cat RELNOTES.md)"

When I run the command in bash terminal I get this output

sh scripts/print-release-notes.sh 
scripts/print-release-notes.sh: line 12: warning: command substitution: ignored null byte in input
□□# Changelog

All notable changes to this project will be documented in this file.

## [1.0.20] - 2022-07-23

### Bug Fixes

- Release job description

### Documentation

- Add docs for changelog using git cliff

### Features

- Git cliff setup

<!-- generated by git-cliff -->

However I want this output.

# Changelog

All notable changes to this project will be documented in this file.

## [1.0.20] - 2022-07-23

### Bug Fixes

- Release job description

### Documentation

- Add docs for changelog using git cliff

### Features

- Git cliff setup

<!-- generated by git-cliff -->

My question is

How to remove this squares □□ <---------

Thank you all in advance

George C.
  • 6,574
  • 12
  • 55
  • 80
  • 1
    If you are reading a file from the Windows world it likely is encoded in UTF-16 with BOM (Byte Order Mark). Using `hexdump -Cv file` will allow you to look at the file in hex and determine what the offending characters are. See [Byte order mark - Wikipedia](https://en.wikipedia.org/wiki/Byte_order_mark) – David C. Rankin Jul 25 '22 at 06:31
  • Yes, this was the problem. It was in UTF-16 by changing the encoding to UTF-8 I fix the issue. Many thanks @DavidC.Rankin – George C. Jul 25 '22 at 16:46

0 Answers0