Showing posts with label Sed. Show all posts
Showing posts with label Sed. Show all posts

Tuesday, June 6, 2017

Remove CTRL-M characters from a file in UNIX

Recently one of my files started getting these ^M characters at the end of each line. I wanted to remove them quickly and use sed to remove them



sed -i "s/^M//" filename
You need to enter ^M by pressing Ctrl and then pressing V and M in succession



Remove CTRL-M characters from a file in UNIX

Monday, May 22, 2017

Change a string in a file based on line number

I came across this situation where I needed to change the timeout of a certain command alone in a script temporarily and automatically. I came across a solution using sed

sed -i "24s/timeoutValue1/timeValue2/" fileName

Ref:
Replace String Based on Line Number