This question already has an answer here:
- Find and remove in unix 4 answers
I need to convert the below awk command into sed,
awk -F ',' '$2 ~ /^ *[0-9]*(\.[0-9]+)?" *$/{sub(/"/, "", $2); print $2}'
Below is my input file:
sample.txt:
3",3"
6-position,6-position
7' 4" to 10' 3-1/2",7' 4" to 10' 3-1/2"
4.8",4.8"
Adjustable from 99" to 111" - max 148,Adjustable from 99" to 111" - max 148
And i need the output as below,
output.txt:
3",3
6-position,
7' 4" to 10' 3-1/2",
4.8",4.8
Adjustable from 99" to 111" - max 148,
So basically I need to print the numeric value for the " symbol, other non-numeric text needs to be replaced by a empty line, the problem with awk command is the 2,3 and 5 line is getting removed.
as I commented, the awk one-liner doesn't make sense for your input file. However you could try this sed line:
this works for your input file.
EDIT
remove
-r
option, and adjust the sed to work with new input/output:This line worked with your new input example:
This works for me:
You can do this with both, awk and sed. Since I have no Linux (shell) on my phone I'll try to help out with a sed solution:
Should do the job