The UNIX and Linux Forums  


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



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
how to delete text from line starting pattern1 up to line before pattern2? repudi8or Shell Programming and Scripting 5 04-15-2008 10:25 PM
Need to serach if a new line character exists on the last line in a file sunilbm78 UNIX for Dummies Questions & Answers 10 02-29-2008 02:15 PM
Changing Line Number of a File ilak1008 Shell Programming and Scripting 17 05-22-2007 02:05 AM
Changing userID and Changing group and GID deal732 Shell Programming and Scripting 2 04-18-2007 11:09 AM
Remove header(first line) and trailer(last line) in ANY given file madhunk Shell Programming and Scripting 2 03-13-2006 03:36 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 06-10-2008
aoussenko aoussenko is offline
Registered User
  
 

Join Date: May 2008
Posts: 119
changing colomn to the line

I have a file which has only one colomn of numbers,ex:
122
173
292
400
979
2152
2339
2376
2387
2446
2450

What ksh / unix command should I use to create a file in which those numbers will be in one line,like this
122 173 292 400 979 .... etc

Thanks a lot for help
  #2 (permalink)  
Old 06-10-2008
jim mcnamara jim mcnamara is offline Forum Staff  
...@...
  
 

Join Date: Feb 2004
Location: NM
Posts: 5,794
One way -

Code:
awk '{printf("%s ", $0) } END {print ""}  ' oldfile > newfile

  #3 (permalink)  
Old 06-10-2008
aoussenko aoussenko is offline
Registered User
  
 

Join Date: May 2008
Posts: 119
Thanks a lot for help
  #4 (permalink)  
Old 06-10-2008
penchal_boddu penchal_boddu is offline
Registered User
  
 

Join Date: Apr 2008
Location: Bangalore
Posts: 127
One more way

cat filename | tr "\n" " "

Thanks
Penchal
  #5 (permalink)  
Old 06-10-2008
vgersh99's Avatar
vgersh99 vgersh99 is online now Forum Staff  
Moderator
  
 

Join Date: Feb 2005
Location: Boston, MA
Posts: 5,131
Quote:
Originally Posted by penchal_boddu View Post
One more way

cat filename | tr "\n" " "

Thanks
Penchal
why exactly do you need 'cat' here?
  #6 (permalink)  
Old 06-10-2008
patelamit009 patelamit009 is offline
Registered User
  
 

Join Date: Mar 2008
Posts: 17
You can even do that using...

echo `cat filename`

It should work.

Amit
  #7 (permalink)  
Old 06-10-2008
penchal_boddu penchal_boddu is offline
Registered User
  
 

Join Date: Apr 2008
Location: Bangalore
Posts: 127
Hi Vgresh,

tr works on strings that input is being provided by cat command.

I dont think i can write like tr "\n" " " filename.

If iam wrong, Please correct me.

Thanks
Penchal
Closed Thread

Bookmarks

Tags
unix commands

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 10:15 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0