Hello All, I am having a problem in automating my UNIX Script to remove the blank spaces in between records. When I incorporate it into my script, the output file is deleting the whole content
Basically this is what I am trying to do:
File contains data like this:
tr -d ' ' <tmscadtrans> tmscadtranstemp1 --> to remove the spaces in between
grep -v "^$" tmscadtemp1> tmscadtranstemp
grep -v "^$" tmscadtranstemp> tmscadtrans --> to remove the blank line at the EOF.
The commands above worked if ran in command prompt but when I run the script it does not work and I do not know what is wrong
But when I double checked my code, it was enclosed in single quotes.
Here is the code:
src=/var/opt/sapbi/TV/scripts/$1
echo $src
sed 'g/^ *$/d' $src
I tried
grep -v "^ *$" $src but it did not work.
I tried the awk commands but nothing happened to the file.
---------- Post updated at 08:32 AM ---------- Previous update was at 08:30 AM ----------
Just wondering, is there an alternative to Gunzip -f <InpFile>? Because upon checking, when the file is gunzipped, it creates those white spaces in between records. When I try to extract using 7zip, it does not add the white spaces.
If non of these work, perhaps there is something invisible on those lines. Run them through od -c to check. Perhaps a CR return character, because the file originated from a Windows platform?
*
0632760 \r \n 2 0 3 1 0 6 7 1 , 7 3 0
0633000 7 , P R T _ F R _ F O S - P R I
0633020 _ S A _ D A M , D 0 0 2 0 2 0 0
0633040 0 0 6 , O 2 4 C , P R T _ F R _
0633060 F O S , , P R I _ S A _ D A M ,
0633100 , . 1 , U S D , 7 3 0 7 , P R T
0633120 _ F R _ F O S - P R I _ S A _ D
0633140 A M , D 0 0 2 0 2 0 0 0 0 6 , O
0633160 2 4 C , P R T _ F R _ F O S , ,
0633200 P R I _ S A _ D A M , , . 1 , U
0633220 S D , 1 3 , 1 0 0 0 0 . 9 , 0 ,
0633240 2 0 1 1 0 1 2 4
0633260
*
0634720 \r \n 2 0
0634740 3 1 4 0 1 9 , 7 9 3 6 , P R T _
0634760 I T _ V C E - P R I _ S A _ D A
0635000 M , D 0 0 2 0 2 0 0 0 0 5 , O 2
0635020 4 C , P R T _ I T _ V C E , , P
0635040 R I _ S A _ D A M , , . 1 , U S
0635060 D , 7 9 3 6 , P R T _ I T _ V C
0635100 E - P R I _ S A _ D A M , D 0 0
Does it mean it plugs-in an '*'? Also, what does \r \n denote? The last record only has that: