bash - sed is adding character to start of word vs end -


so i'm trying add "!" end of every word in placescapex file placescap file

this looks like: yugoslavian zambia zambian zomba

this want like: yugoslavian! zambia! zambian! zomba!

i've tried sed 's/$/\!/' wordlists/placescap > wordlists/placescapex , sed 's/$/!/' wordlists/placescap > wordlists/placescapex

what happens when run , cat wordlists/placescapex outputs !ugoslavian !ambia !ambian !omba

i've done research , stated being unix thing never went detail

your simpler sed command should work fine text file end-of-line single newline character. have "dos" format files here (carriage return / linefeed).

consider:

$ cat zippy zippy $ od -c zippy 0000000   z     p   p   y  \r  \n 0000007 $ sed 's/$/!/' zippy !ippy $ sed 's/$/!/' zippy | od -c 0000000   z     p   p   y  \r   !  \n 0000010 

you're seeing effect of \r displayed on terminal: move cursor start of line, print '!', newline goes next line.

to handle presence of \r\n pairs end-of-line character, might try:

$ sed 's/\r*$/!/' zippy zippy! 

...assuming sed honors \r mine (gnu sed 4.2.2) does.


Comments

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -