naming columns


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting naming columns
# 1  
Old 02-11-2011
naming columns

i have a file staff.txt with contents
Code:
tom|25|New York
sims|40|London
neyo|18|Moscow

i want to label the column at the top, my output should be
Code:
Names|age|city of birth
tom|25|New York
sims|40|London
neyo|18|Moscow

# 2  
Old 02-11-2011
Code:
awk 'BEGIN{print "Names|age|city of birth"}1' file

# 3  
Old 02-11-2011
Code:
$
$
$ # Check the content of "staff.txt"
$
$ cat staff.txt
tom|25|New York
sims|40|London
neyo|18|Moscow
$
$
$ # Run the command pipeline to add a header
$
$ echo "Names|age|city of birth" | cat - staff.txt > tmp.txt && mv tmp.txt staff.txt
$
$
$ # Now check the content of "staff.txt" again
$
$ cat staff.txt
Names|age|city of birth
tom|25|New York
sims|40|London
neyo|18|Moscow
$
$

tyler_durden
# 4  
Old 02-11-2011
thanks so much, both are working
# 5  
Old 02-11-2011
Code:
 $ ruby -ne '$_="Names|age|city of birth\n#{$_.chomp}\n" if $.==1;print ' file

Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Cybersecurity

Proper naming conventions

Hey guys, not sure should I post it here or in 'What is on Your Mind?' I'm discussing usage of DSL (domain specific language) in security tools with my colleagues. We haven't been able to reach an agreement over naming conventions. There are many tools using DSL: splunk, sumologic,... (2 Replies)
Discussion started by: Tobby P
2 Replies

2. Shell Programming and Scripting

Help with naming the file

Hi, I have a folder that contains files abc.txt def.txt ....and so on Inside abc.txt, I have @<TRIPOS>MOLECULE 4|Chelerythrine|abcb11_earlyIdentification_Stronginhib_washed_ligprep|sdf|1|dock Inside def.txt, I have @<TRIPOS>MOLECULE... (6 Replies)
Discussion started by: rossi
6 Replies

3. What is on Your Mind?

Humorous naming

Dear all, We've been asked to submit names for our documentation system. It used to be the very dry ISDL (Information Services Documentation Library) The replacement is built on a Wiki-beastie but that doesn't help much with a name. I wondered about an acronym based on CRAFT, so I can... (1 Reply)
Discussion started by: rbatte1
1 Replies

4. UNIX for Dummies Questions & Answers

naming files in awk

I have a whole directory and I need each lines of each file to be separated to a new file but I am facing problem naming them :( some of the files even might be empty the output files should be names original file name + the number of the line or any incremental number FILES="data/*" for X in... (12 Replies)
Discussion started by: A-V
12 Replies

5. Shell Programming and Scripting

#file naming

hi all, Please advise at what circumstance those file will become -rwxr-xr-x 1 psa psa 1969088 Aug 18 2006 #libaa.sl -rwx------ 1 psa psa 2166784 Jul 25 2006 #libcrypto.sl.0.9.7 -rwx------ 1 psa psa 904040 Jul 25 2006 #libxxx.sl -rwx------ 1 psa ... (2 Replies)
Discussion started by: rauphelhunter
2 Replies

6. Shell Programming and Scripting

issue in naming a file

Hi, I want to create a file named 'abc(+1)' and append the data of file 'abc' to it. But getting error as unexpected'(' when i tried to use the following command. cat abc > abc(+1) Is there any other way to include brackets along with +1 in the file name? TIA. (3 Replies)
Discussion started by: vimalr
3 Replies

7. UNIX Desktop Questions & Answers

Naming convention for Libraries..

Hi All, I need to know standard naming convention for Unix libraries (including all flavours of unix)..As I have gone through some sites and found out The UNIX convention for naming of libraries is lib<name>.so.<major>.<minor>.<revision> so is it statndard . also does it change... (0 Replies)
Discussion started by: rkshukla14
0 Replies

8. Programming

Naming a socket

Im not very experienced with C so this is probably a basic question. I have a script that opens up 5 sockets, it then runs through a loop and on a given event reconnects to the relevant socket and sends some data. The socket to be reconnected to is kept track of with a 'count' variable. The sockets... (5 Replies)
Discussion started by: geester
5 Replies

9. UNIX for Advanced & Expert Users

Controller Naming

Hello all, How does the Solaris identifies the controller subscript ? ( like c0txdxs0 or c1txdxsx ?? ) I have a unix box ( Ultra 30) running with 2.5.1. When I connected an external hard disk to the on-board scsi port, it got identified as c0t1dxsx... (... (1 Reply)
Discussion started by: shibz
1 Replies
Login or Register to Ask a Question