I'm trying to delete the blank lines from the file $Sfile. tried the below set of commands. Both are giving the same error (: bad interpreter: No such file or directory)
awk 'NF > 0' $Sfile > $Tfile
cat $Tfile
sed -i '/^$/d' $Sfile
cat $Sfile
Not sure if there's any other problem with the program. But without the above scripts, the program is working fine. But I need this logic to be put, in order to remove the blank lines, as it is causing some issues.
Please explain the complete logic of what you want the script to do as in the initial posting you just mentioned removing blank lines from the filename contained in a variable.
Pfile is the one that has the data.
It has few lines with '-' and 'PRCSINSTANCE', which I'm deleting here with the grep commands.
The other files, I'm using it for temporary storage.
Here I'm trying to get the final result (without any blank space or lines with '-' or 'PRCSINSTANCE') into the $Sfile
If exec can't find the interpreter, none of the script executes, including set -x.
It's almost certainly a carriage return at the end of the interpreter line. Not only would it explain why the interpreter can't be found (it's looking for a file whose basename is sh<carriage return>), it also explains why there's no interpreter name before the first colon in the error message (after the bad interpreter name is printed, the cr returns the cursor to the beginning of the line and the subsequent characters in the error message overwrite it).
Thanks Alister and all.
You were dead right. I had edited in Windows. After I edited with vi editor, the error never appeared again.
Still the below code did not take any effect :
sed -r '/^$|-|PRCSINSTANCE/d' $P_FILE
After I gave the same code to print the result to another file, it worked.
sed -r '/^$|-|PRCSINSTANCE/d' $P_FILE > $O_FILE
Thanks again to everyone who had assisted me so patiently. You all made my day!!!