Reputation: 51
I have a file with hundreds of lines with contents that looks like this:
6281316
6281315
6281317
I simply want to use awk to transform them into regex expression so I could use it later.
/6281316/
/6281315/
/6281317/
howerver, when I run:
awk '{print "/"$1"/"}' file.txt
it give back
/6281316
/6281315
/6281317
Does anybody could point out where I went wrong?
Thank you very much
Upvotes: 1
Views: 74
Reputation: 77085
There is nothing wrong with your command. Your file has windows formatting. Convert the file to unix format using dos2unix
and re-run the command.
Upvotes: 3
Reputation: 947
Your command works for me without any issue. Maybe try a sed solution:
sed 's/^/\//;s/$/\//' file.txt
Upvotes: 0