Ravi


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Ravi
# 1  
Old 02-22-2008
Ravi

We have one UNIX server , I'm trying to use a multi-line printing using awk command. The sample input file is given below

1
SYSCATSPACE
System managed
4584

1
TEMPSPACE1
System managed
1

2
USERSPACE1
System managed
416

3
SYSTOOLSPACE
System managed
91

4
SYSTOOLSTMPSPACE
System managed
1

And my output file should look like this

0 SYSCATSPACE System manageda 4584
1 TEMPSPACE1 System managed 1
2 USERSPACE1 System manageda 416
3 SYSTOOLSPACE System managed 91

How do i print multiple records using awk command,
your help will be highly appreciated in this regard.

Regards

Ravi

edit by bakunin: Ravi, please keep the following two issues in mind:

1. Give your threads some meaningful title. The questions you pose along with the answers are going to a permanent knowledge database (the forums archive) and other users can and do search this database. If someone has a similar problem like you s/he should be able to enter "multiline print" or something such as keyword and find your thread. This is why naming threads "Ravi" or "i have a problem" or so is a pretty bad idea.

2. The baord has theme-oriented subsections. The section you posted in is dealing with AIX issues. You might be working on an AIX machine, but the problem you posed is clearly not AIX-related. There is a section "Shell scripting" where this thread would fit much better. I'm going to move it over to there in this case, but, please, try to put your thread in the right part yourself. Thank you.

Last edited by bakunin; 02-23-2008 at 07:35 AM..
# 2  
Old 02-23-2008
Code:
$ awk 'BEGIN {RS=""; FS="\n"; ORS="\n" } {printf "%s %s %s %s\n", $1, $2, $3, $4 }' ravi.txt 
1 SYSCATSPACE System managed 4584
1 TEMPSPACE1 System managed 1
2 USERSPACE1 System managed 416
3 SYSTOOLSPACE System managed 91
4 SYSTOOLSTMPSPACE System managed 1

Cheers,
ZB
# 3  
Old 02-25-2008
Shell Programming and Scripting

Thank you ZB,
I have tried your command , but it is only selecting the first record and skipping the remaining records.Please help.

$ awk 'BEGIN {RS=""; FS="\n"; ORS="\n" } {printf "%s %s %s %s\n", $1, $2, $3, $4 }' ravi.txt
1 SYSCATSPACE System managed 4584


Regards

Ravi
Login or Register to Ask a Question

Previous Thread | Next Thread
Login or Register to Ask a Question