I want to delete three words with a special character on a line such as
Input:
\cf4 \cb6 1749,1789 \cb3 \
Output:
1749,1789
I have tried a couple sed and grep statements but so far none have worked, mainly due to the character \
.
My unsuccessful attempt:
sed -i 's/ [.\c ] //g' inputfile.ext >output file.ext
Awk accepts a regex Field Separator (in this case, comma or space):
$ awk -F'[ ,]' '$0 = $3 "." $4' <<< '\cf4 \cb6 1749,1789 \cb3 \'
1749.1789
-F'[ ,]'
- Use a single character from the set space/comma
as Field Separator$0 = $3 "." $4
- If we can set the entire line $0
to Field 3 $4
followed by a literal period "."
followed by Field 4 $4
, do the default behavior (print entire line)Replace <<< 'input'
with file
if every line of that file has the same delimeters (spaces/comma) and number of fields. If your input file is more complex than the sample you shared, please edit your question to show actual input.
could you please be so kind as to explain to me what exactly you did there as i am struggling to understand that command. would that work on a file that has multiple lines ?
Thank you very much! The source consists of n lines of the same style so I would say it is not complex