File not found when using cygwin

files="UserRightAssignment.txt"
echo $files
echo '1.1.1.2.2.1;'        `grep -ai '^Modify an object label' $files`

Hi there, I got such an output when using unix,please advise

1.1.1.2.2.1;
: No such file or directoryxt

I am using

sh ura.sh

I would say your "files" variable has a CTRL-M at the end of it. Perhaps you have txt files in DOS format from where this variable name has been read?

$ files="UserRightAssignment.txt^M"
$ grep test "$files"
: No such file or directoryxt

Hi,

I have tried converting the file from dos2unix using cygwin and append and ^M towards the end of the files but both ways does not work.

Hello alvinoo,

To confirm about ^M characters in a file could you please use following command.

 cat -v Input_file
 

Now if above command gives you positive results about file having ^M characters, then you can try following command too.

 tr -d '\r' < Input_file >Output_file
 

Hope this helps.

Thanks,
R. Singh