filename is distorted with '$/r' appended to filename [duplicate]

I am trying to learn linux commands so please bear with any ignorance. I am creating a file with cut command which is written in Script.sh file. But when the file is created it adds '$/r' to end of the filename. So further operations on the created file does not executes as no file is found with the given name.

cut somefile.csv -d"," -f1 > file1

so the file1 is created with name as 'file1$/r/' Any help is highly appreciated

Edit :

cut inputFile -d"," -f6 >file1
cut inputFile -d"," -f1 >file2
paste -d"," file1 file2 > result
11

1 Answer

This is probably caused by the file encoding of the script.

The $/r garbage at the end of the file name is the windows chars for a new line.

If you created the file Script.sh in an windows environment, then copy the text and paste it into a proper UNIX editor, save and try again.

You Might Also Like