1

There is a table with data.

./result_4_0.txt
./result_4_45.txt
./result_4_45.txt
./result_4_0.txt

I want to create two columns from numbers. How can I replace "./result_" "_" ".txt" just with space. I tried before sed but it does not work together with dot or slash.

file="filename.txt"
while IFS= read line

do

done <"$file"
0
$ tr -dc "\n0-9_" < input | awk -F_ '{print $2,$3}'
4 0
4 45
4 45
4 0
1

sed perfectly works with dots and slashes. You just need to escape those:

sed 's/\(\.\/result_\|_\)/ /g' filename.txt

Or, if you want more readability, something like that will also do:

sed 's=\./result_= =;s=_= =' filename.txt

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.