Removing new lines from a file
Can any body tell me whether there is any command in bash shell that removes new line(i.e"\n") from a file
|
You need to give us more information if you want a decent response.
This can be done with tools like sed, or you could write a script in perl. I hope this isn't homework ;) --Ian |
This thread might help:
http://www.linuxquestions.org/questi...d.php?t=530376 |
sed -n 'H;${g;s/\n/ /g;p}'
|
Quote:
|
For this general class of problems, there are three Unix/Linux tools that you need to be aware of.
(a) sed ("stream editor") is a tool that can take an input stream (file...), apply a filter or change to it, and write it to an output stream. This tool is usually used with the "|" (pipe) operator in a command. (b) grep ("regular expressions") is a great tool for finding files and for extracting useful pieces from those files. (c) awk is a very powerful tool for ripping a file apart, record-by-record and field-by-field, and doing very sophisticated things with them. Obviously, above-and-beyond this, programming languages like perl and python feature hundreds of pre-built packages of existing code for doing these things and more. Important Tip... In the Unix/Linux world, there are many ways to do just about anything, and most if not all of them have already been done. Usually, when you think about "building" a solution, you just need to "find" one. Quote:
|
All times are GMT -5. The time now is 04:11 AM. |