tr - Removing carriage return and tab escape sequences from string in Bash -
assume have string:
your name is\nbobby\tblahck\r\r
how can remove characters "\n, \t, \r". string literally looks that, not contain tabs or new lines. characters.
when try
echo "your name is\nbobby\tblahck\r\r" | tr -d '\t'
tr assumes trying remove tabs, doesn't work , prints examtly same string. ideas how remove them? have same problem sed.
thanks
$ echo "your name is\nbobby\tblahck\r\r" | sed -e 's,\\t|\\r|\\n,,g' name isbobbyblahck
or
$ echo "your name is\nbobby\tblahck\r\r" | sed -e 's,\\[trn],,g' name isbobbyblahck
-e
on os x; replace -r
otherwise.
Comments
Post a Comment