Insert Title To Each Lines


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Insert Title To Each Lines
# 1  
Old 11-05-2008
Insert Title To Each Lines

I have a command that returns following, but it's missing a title for each line.

YOUR FULL NAME
YOUR ID
YOUR EMAIL
YOUR ADDRESS
YOUR PHONE

Now, I want to add its title to each line:
Name: YOUR FULL NAME
ID: YOUR ID
Email: YOUR EMAIL
Address: YOUR ADDRESS
Phone: YOUR PHONE

Thanks for your help.
# 2  
Old 11-05-2008
Code:
% print 'YOUR FULL NAME
YOUR ID
YOUR EMAIL
YOUR ADDRESS
YOUR PHONE'|perl -lape'$_=ucfirst(lc($F[-1])).": ".$_'
Name: YOUR FULL NAME
Id: YOUR ID
Email: YOUR EMAIL
Address: YOUR ADDRESS
Phone: YOUR PHONE

# 3  
Old 11-05-2008

Ideally, you should fix the command so that it ouputs what you want.

If that is not an option:

Code:
COMMAND | awk '
        NR == 1 { print "Name: " %0 }
        NR == 2 { print "ID: " %0 }
        NR == 3 { print "Email: " %0 }
        NR == 4 { print "Address: " %0 }
        NR == 5 { print "Phone: " %0 }
'

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Insert title as output of command to appended file if no output from command

I am using UNIX to create a script on our system. I have setup my commands to append their output to an outage file. However, some of the commands return no output and so I would like something to take their place. What I need The following command is placed at the prompt: TICLI... (4 Replies)
Discussion started by: jbrass
4 Replies

2. Shell Programming and Scripting

Insert text before first 'n' lines

I want to put a particular text, say, the hash '#' before each of the first n lines of a file. How can I do that? (4 Replies)
Discussion started by: hbar
4 Replies

3. Shell Programming and Scripting

awk to insert duplicated lines

Dear All, Suppose I have a file: 1 1 1 1 2 2 2 2 3 3 3 3I want to insert new line under each old line so that the file would become: 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 3 3 3 3 3 3 3 3How can this be accomplished using awk (or sed)? (5 Replies)
Discussion started by: littlewenwen
5 Replies

4. Shell Programming and Scripting

Insert at the beginning of odd lines

Hello people, I am trying with sed to insert some text at the beginning of each odd line of a file but no luck. Can you please help. Awk is also suitable but I am not very familiar with it. Thank you in advance for any help. (7 Replies)
Discussion started by: drbiloukos
7 Replies

5. Shell Programming and Scripting

Insert a string instead of blank lines

how can i insert a string sush as "###" instead of blank lines in a file? i try this code but it doesn't work! awk 'NF<1 {$1=="###" ; print$0}' in_file > out_file (13 Replies)
Discussion started by: oreka18
13 Replies

6. Shell Programming and Scripting

sed - insert two lines

I have done this sed command to insert one line after a specific string is found: sed '/patternstring/ a\ new line string' file1 But how do I insert two lines? This is not possible: sed '/patternstring/ a\ new line string \a new line string 2' file1 (2 Replies)
Discussion started by: locoroco
2 Replies

7. Linux

how to insert a title into a window in kshell

hi all, i am using a Ubuntu work station. i have following piece of code that works ok. But i cant figure out a way to insert a string call $Name into the title of the window i am opening. As you can see, i tried two different ways without a success. Can someone please help me out here? :( ... (3 Replies)
Discussion started by: usustarr
3 Replies

8. Shell Programming and Scripting

Insert between lines.

Hello...I'm here again. This is the situation I want check if exist text between two lines: Example: interface description --text to verify ip adress if not exists text between 'interface' and 'ip address' i want insert the word 'no description' interface no description --if not... (4 Replies)
Discussion started by: bobbasystem
4 Replies

9. Shell Programming and Scripting

[Perl] Insert lines before lines.

Hi, New problem, or challenge as they prefer in the US. I need to insert some lines in a file before certain other lines. To make it more clear: Original file: aaaa bbbbb ccccc ddddd bbbbb fffff ggggg Now I want to insert the line "NEW_NEW_NEW" when I match "fffff", but I want... (7 Replies)
Discussion started by: ejdv
7 Replies

10. Shell Programming and Scripting

Insert lines between delimiters

I'm working with a file like: somestuff somemorestuff ... someadditionalstuff STARTTAG ENDTAG someotherstuff somecoolstuff ... somefinalstuffI've got some text (either in a file or piped) to put between STARTTAG and ENDTAG. I was thinking something like grepping for the line number of... (2 Replies)
Discussion started by: BMDan
2 Replies
Login or Register to Ask a Question