Sample txt file :
OK00001111112|
OK00003443434|skjdaskldj
OK32812983918|asidisoado
OK00000000001|
ZM02910291029|sldkjaslkjdasldjk
what would be the shell script to figure out the blank space (if any) after the pipe sign?
Sample txt file :
OK00001111112|
OK00003443434|skjdaskldj
OK32812983918|asidisoado
OK00000000001|
ZM02910291029|sldkjaslkjdasldjk
what would be the shell script to figure out the blank space (if any) after the pipe sign?
Your sample input doesn't appear to have any spaces or tabs after the vertical bars. But, the code:
awk -F '|' '$2 ~ /[[:blank:]]/' file.txt
when file.txt contains:
OK00001111112|
OK00003443434|skjdaskldj
OK32812983918|asidisoado
OK00000000001|
ZM02910291029|sldkjaslkjdasldjk
abc| space
def| tab
ghi|12 34space
jkl|56 78tab
produces the output:
abc| space
def| tab
ghi|12 34space
jkl|56 78tab
Is this what you were trying to do?
yeah, I noticed it now that there is no blank space after the | in sample.txt file.
I wish to print the rows which have only one column (ie. missing 2nd column after | )
output should look like :
Blank Records found :
OK00001111112|
OK00000000001|
There is a big difference between "blank" and "empty". To print lines where field 2 is empty, try:
awk -F '|' '$2==""' file.txt
Thanks a Ton Don!.. It worked..