The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #4 (permalink)  
Old 03-17-2009
cfajohnson's Avatar
cfajohnson cfajohnson is offline Forum Advisor  
Shell programmer, author
  
 

Join Date: Mar 2007
Location: Toronto, Canada
Posts: 2,361
Quote:
Originally Posted by narang.mohit View Post
hey i m newbie i dont know whether this is happining in my terminal or is there any reason behind this
here it is
when i do
1.) sed -n 's/\t/\n/gp' space > enter #where space is tab seperated file
it works fine it give me a outupt that all tab seperated convert into column

but when i tried to reverse this it wount work
2.) sed -n 's/\n/\t/gp' enter > space

There can be no newline inside a line read from a file.
Quote:

it wouldnt give me any output
i know there is an alternative for this
3.) cat enter | tr "\n" "\t"

No need for cat:

Code:
tr "\n" "\t" < enter
Or:

Code:
awk '{ printf "%s\t", $0 }' enter