Hello yazu,
When I execute your command on the console, it is successful in producing the desired results.
However, I am having difficulty incorporating it into my final script. I have copied a version of it below for review. I've tried several ways and when executing the script, I am getting errors such as "broken pipe" or "garbled." The last row is still being removed.
Can someone please review my script and let me know how I am supposed to incorporate the proper syntax so my last record is not deleted?
In a nutshell, this script is to take the original file, emfdata.asc, replace all 3-char delimiters (*~|) with only pipes...Then delete the first row (column headings)...Finally write it to a file called emfdata.dat.
#!/bin/sh
if [ -s /test/dir/a00/datafiles/emf/emfdata.asc ]
then
sed -e 's/*~|/|/g' -e 's_.*_|&_' /test/dir/a00/datafiles/emf/emfdata.asc > /test/dir/a00/datafiles/emf/emfdata.tmp
sed '1d' /test/dir/a00/datafiles/emf/emfdata.tmp > /test/dir/a00/datafiles/emf/emfdata.dat
mv /test/dir/a00/datafiles/emf/emfdata.asc /test/dir/a00/datafiles/emf/emfdata.asc.old
rm /test/dir/a00/datafiles/emf/emfdata.tmp
fi
A couple of additional things: I think maybe the last line being deleted is occuring after the first sed command too...not the second, as I found out when I did the output to screen. Also, my script produces the correct results for a test file with only 5 records, but is not for a file containing 185 records...Why is that?
Thank you in advance!
