I am having dificulty trying to print lines with white space only and excluding the rest like below.
Inside test.txt
francoiv|538|
gerardl|520|
icell|548|
icell |787|
ieppcnf|791|
ieppix |788|
ieppvas|792|
ifastrk|790|
iinter|558|
iinter |793|
ixaeppix|795|
ixaepprp|796|
ixaint|772|
ixaint |794|
ixarocel|771|
ixaroint|773|
karsc001|1051|
mafokokg|535|
makgotma|528|
The expected output I require is below.
icell |787|
ieppix |788|
iinter |793|
ixaint |794|
I have tried so many sed and awk options online and I can't seem to come right. The number of white spaces can be more than 2 so I was trying to use a command that can find before the pipe [|] a whitespace or blank character, but I can't find a way to do this.
When I use cat -v test.txt to display special character, I get below.
francoiv|538|
gerardl|520|
icell|548|
icellM- M- |787|
ieppcnf|791|
ieppixM- |788|
ieppvas|792|
ifastrk|790|
iinter|558|
iinterM- |793|
ixaeppix|795|
ixaepprp|796|
ixaint|772|
ixaintM- |794|
ixarocel|771|
ixaroint|773|
karsc001|1051|
mafokokg|535|
makgotma|528|
Not sure what M- means
If the space is in the end of the first field, use:
Explained:
awk -F\|using awk, pipe is the field separator$1first field~/ +$/ends in one or more spaces