Add text before lines in command output


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Add text before lines in command output
# 1  
Old 06-18-2008
Add text before lines in command output

Hi2all,

I have following command in IBM HMC console:
lssyscfg -r prof -m Server-9117-MMA-SN655D350 -F lpar_name,min_mem,desired_mem --header

which gives me the following output:

lpar_name,min_mem,desired_mem
lpar1,1024,2048
lpar2,1024,2048
lpar3,2048,4096

What I want is to add in the begining of every line starting from lpar1, name of the Complex. How can I achieve this?
# 2  
Old 06-18-2008
Try something like this:

Code:
awk '/lpar1/{$0="name of the Complex"$0}1' output_file

Regards
# 3  
Old 06-18-2008
Or maybe you mean add a string on every line except the first?

Code:
awk 'NR > 1 { $0="name of the Complex" $0 }1' output_file

If "name of the Complex" is not meant as a static string, but something you can derive programmatically somehow, you need to tell us how to obtain it.
# 4  
Old 06-18-2008
Yes, guys that would be it, thank you very much.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

awk to add value and text to specific lines

In the awk I have a very large tab-delimeted file that I am trying to extract the DP= value put it in $16 and add specific text to $16 with . (dot) in $11-$15 and $18. Only the lines (there are several) that have the formating below in file will have an empty $16. Other lines will be in a... (6 Replies)
Discussion started by: cmccabe
6 Replies

2. Shell Programming and Scripting

awk to add lines with symbol to output file

In the awk below which does execute I get output that is close, except for all the lines that start with a # are removed. Some lines have one others two or three and after the script adds the ID= to the fields below the pattern in the awk, I can not seem to add the # lines back to the output. ... (5 Replies)
Discussion started by: cmccabe
5 Replies

3. Shell Programming and Scripting

awk to skip lines find text and add text based on number

I am trying to use awk skip each line with a ## or # and check each line after for STB= and if that value in greater than or = to 0.8, then at the end of line the text "STRAND BIAS" is written in else "GOOD". So in the file of 4 entries attached. awk tried: awk NR > "##"' "#" -F"STB="... (6 Replies)
Discussion started by: cmccabe
6 Replies

4. Shell Programming and Scripting

E-mail Output Merge Lines for Some Text..

Hi all. This is the content of the text file used for the e-mail: TM ICP-EDW BILLING REGISTER USAGE BREAKDOWN_01062014.csv TM_ICP_EDWH_FICL_13062014.TXT TM_ICP_EDWH_FICL_16062014.TXT TM_ICP_EDW_Detailed Payment Journal Report_13062014.txt TM_ICP_EDW_Detailed Payment Journal... (9 Replies)
Discussion started by: aimy
9 Replies

5. UNIX for Dummies Questions & Answers

How to parse 2 particular lines from Command output

Hi All, I need help on the following req. I am getting output of a command as follows: 16377612 total memory 3802460 used memory 2827076 active memory 681948 inactive memory 12575152 free memory 477452 buffer memory I want to compute used... (1 Reply)
Discussion started by: mailsara
1 Replies

6. Shell Programming and Scripting

How to cut selected lines from command output

Hi guys, I need to cut the first 12 system processes from the command ps -A. I know that the cut command forms part of the pipeline but can't understand how to cut the first 12 lines and later display them on standard output. Please help! Many thanks, Jared. (3 Replies)
Discussion started by: jjb1989
3 Replies

7. UNIX for Dummies Questions & Answers

Which command can help me output lines with duplicate numbers?

i have a file, let's call it file. march 2008 january 2008 march 1920 march 2002 i want to output the first line, not the second as you can see the second line has different numbers. (8 Replies)
Discussion started by: hobiwhenuknowme
8 Replies

8. Shell Programming and Scripting

How do I capture multiple lines of the status output of a command?

I need to know what the upload speed of an Internet connection. I thought the easiest way to do this would be to transfer a file via FTP to my server using the command: sh-3.2$ ftp -u ftp://username:password@computerdomain/directory/ file_to_be_uploaded Note: My environment allows me to issue... (2 Replies)
Discussion started by: zzz1528
2 Replies

9. UNIX for Dummies Questions & Answers

add new lines of text before and after each input line

I have a file that contains hundreds of lines such as: this_is_macro,000001 this_is_macro,000002 this_is_macro,000003 I would like to add the variable words MACROBEGIN MACRO_000001 MACROBEGIN MACRO_000002 MACROBEGIN MACRO_000003 above each line and add the word MACROEND ... (2 Replies)
Discussion started by: kenneth.mcbride
2 Replies

10. Shell Programming and Scripting

need to search text and output previous lines

I have a file (OMlog0) that is quite large, I need to find the line "Automatic Recharge Audit Process Finished" and output that line and the time stamp that occurs two lines previous. The line that I was using is "sed -n '/Automatic Recharge Audit Process Finished/,/No errors/p' /sn/log/OM* >... (8 Replies)
Discussion started by: grinds
8 Replies
Login or Register to Ask a Question