I am having issues with deleting the line from a file. My program will check for a particular condition using while and if loop and if it matches then delete the line from the file. But while deleting I am getting the error like " sed: can't read". I think I am near to the solution but unable to get sort it out. Below is the code I am using.
#!/bin/ksh File='dsgp_p50.dat' cd /home/lpadmin while read -r line do x=`echo "$line" | cut -c 75-104` echo $x if [ $x == '00000000000000+00000000000000+' ] then sed '1,1d' "$line" > vikas.dat fi done < $File
I have a file which contains data in the below form.
507425B30 171013D248900022 4057-ACCR PROPERTY TAX 00000000257910+00000000000000+00000000257910+00000000000000+00000000000000+ 507425B30 171013C249999092 1071-DO NOT USE 00000000000000+00000000000000+00000000000000+00000000031940+00000000000000+
Now i have to delete the lines which contains the pattern like 00000000000000+00000000000000+ ( The position of this pattern in the file is 75-104) and the tricky part is that we have to delete the line only when it comes in the 1st occurrence in the same line. There will be scenarios like the first record in the above where the pattern came at the last and it should not delete the line from the file. It should delete the line only when the pattern 00000000000000+00000000000000+ comes in the position 75-104.