Reputation: 47
I have one file(file1.txt)
Rahul=rahul
Vimal=vimal
Vishal =vishal
Rupesh =rupesh
Aromal =aromal
Anugrah =anugrah
My output file should be
Rahul=rahul
Vimal=vimal
Vishal=vishal
Rupesh=rupesh
Aromal=aromal
Anugrah=anugrah
I tried with following commands. Still not getting output as I needed.
sed 's/ */ /g' < file1.txt
sed 's/ \{1,\}/ /g' < file1.txt
sed 's/ \+ / /g' < file1.txt
sed -e "s/[[:space:]]\+/ /g" < file1.txt
Upvotes: 1
Views: 28
Reputation: 1461
You can use shell tr
command if not required to use sed:
tr -d ' ' < file1.txt
Hope this helps
Upvotes: 0
Reputation: 785761
You may use this sed
with an alternation in your regex:
sed -E 's/^[[:blank:]]+|[[:blank:]]+(=)/\1/g' file
\1
is back-reference for capture group #1 i.e. =
in 2nd part of alternation.
Rahul=rahul
Vimal=vimal
Vishal=vishal
Rupesh=rupesh
Aromal=aromal
Anugrah=anugrah
Upvotes: 1