Here's my current command:
sed 's/\./-/' file.txt > CLEANED.txt
What I'm trying to do is replace all periods in my file with a dash. Some lines have multiple periods and I need all of them replaced with a dash - but the command above seems to just replace the first one in each line.
What am I doing wrong for it to not replace all of the periods?
In perl, just add the /g
modifier to your regex:
perl -pe 's/\./-/g' file.txt > CLEANED.txt
Explanation:
Switches:
-p
: Creates awhile(<>){...; print}
loop for each “line” in your input file.-e
: Tellsperl
to execute the code on command line.
Code:
s/\./-/g
: Replace all periods with dashes. Could also use the transliteration operator:y/./-/