changing colomn to the line


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting changing colomn to the line
# 1  
Old 06-10-2008
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  
Old 06-10-2008
One way -
Code:
awk '{printf("%s ", $0) } END {print ""}  ' oldfile > newfile

# 3  
Old 06-10-2008
Thanks a lot for help
# 4  
Old 06-10-2008
One more way

cat filename | tr "\n" " "

Thanks
Penchal
# 5  
Old 06-10-2008
Quote:
Originally Posted by penchal_boddu
One more way

cat filename | tr "\n" " "

Thanks
Penchal
why exactly do you need 'cat' here?
# 6  
Old 06-10-2008
You can even do that using...

echo `cat filename`

It should work.

Amit
# 7  
Old 06-10-2008
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
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Remove duplicate in colomn

i have a file which have two columns, 2nd column have duplicate values and i want to delete and keep only distinct on basis on 2nd column. -bash-4.1$ cat file_re 7440 713543695 7441 713543695 4603 714457614 4602 714457614 40301 717937765 40281 717937765 33741 721208982... (2 Replies)
Discussion started by: mirwasim
2 Replies

2. Shell Programming and Scripting

Changing Line in Txt File

So I have a python program that I run, which runs accordingly to options I have listed in a text file (ie user_prefs). Now there are many options listed in this user_prefs.txt, but the one of most interest to me is that of the file path of the time series. I have over a hundred of these time... (8 Replies)
Discussion started by: Jimmyd24
8 Replies

3. Shell Programming and Scripting

Need Help!!! For changing the content of the line

I need to change the content of the line after I grep it. The line is : Date SNWD.I-1 (in) WTEQ.I-1 (in) PREC.I-1 (in) TOBS.I-1 (degC) TMAX.D-1 (degC) TMIN.D-1 (degC) TAVG.D-1 (degC) I want to change the second column (SNWD.I-1(in)) to SNWD.I-1(m), how could I do that? I use csh... (2 Replies)
Discussion started by: handsonzhao
2 Replies

4. Shell Programming and Scripting

Need help in changing vertical lines to horizontal line in a file

Hi, I have a file like below robert PREF: 3 AVAIL: henry PREF: 234 AVAIL: john PREF: 145,178 AVAIL: 123 matt PREF: 564,932 AVAIL: ten PREF: 389 AVAIL: kill (2 Replies)
Discussion started by: rocky1954
2 Replies

5. Shell Programming and Scripting

How to exclude certain colomn from the file?

Hi I have a file in the following format: 4135 f4135acc: 39798 rmtdb: 0 /t1/data/f4135acc.dta 4135 f4135pdb: 39795 rmtdb: 0 /bb/data/f4135pdb.dta 4135 p4135eng: 0 rmtdb: 0 /bb/bin/p4135eng 4135 r4135eng: 14142 rmtdb: 0 ... (6 Replies)
Discussion started by: aoussenko
6 Replies

6. Shell Programming and Scripting

changing line on a file

Hi, I want to change on a file this line: vif = into: vif = But there are some conditionals: 1. last part '] of the original line after 00:16:3E:CE:23:14' ] may vary to 00:16:3E:CE:23:14' ] or 00:16:3E:CE:23:14 ' ] 2. The second mac adrress of the line I need,... (4 Replies)
Discussion started by: iga3725
4 Replies

7. Shell Programming and Scripting

changing from command line to perl script

I had posted previously about this problem I had. I have multiple text files with hundreds of lines of the following type: 2000001 34 54 234 2000001 32 545 2000001 -2000001 77 2000001 44 2000001 998 2000001 77 32 2000001 45 23 111 89 98 75 23 34 999 . . . etc... What I wanted was... (2 Replies)
Discussion started by: xchen89x
2 Replies

8. AIX

Yesterday's date without changing anything and in one cmd line ?

I have seen references in the forum about getting yesterday's date but it is either by changing something in the system (date, time zone, ...) or with more then one line of script cmds. How can I get yesterday's date without changing anything in the system and in one single command line ? (4 Replies)
Discussion started by: Browser_ice
4 Replies

9. Shell Programming and Scripting

switch line to colomn

Hi It's possible to switch the line to colon from a file using Perl or AWK? for example my file have somthing like this: 10 11 12 13 14 20 21 22 23 24 30 31 32 33 34 I want to have a file with the line switched like : 10 20 30 11 21 31 12 22 32 13 23 33 14 24 34 Thanks a lot (4 Replies)
Discussion started by: rauchy
4 Replies

10. Shell Programming and Scripting

Changing Line Number of a File

Example: O o x What I would like to do is to rename the first column of the above file without affecting the format. The output should look like the following: Output: O o x #! /bin/ksh cd $HOME/lib/.Lee #nl = no. of lines. nl=`grep 'X' ex | wc -l` #ln = line no. ln=1 (17 Replies)
Discussion started by: ilak1008
17 Replies
Login or Register to Ask a Question