![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| capturing output from top and format output | new2ss | Shell Programming and Scripting | 4 | 02-24-2009 09:26 PM |
| Output format - comparison with I/p file | velappangs | Shell Programming and Scripting | 1 | 04-03-2008 06:31 AM |
| To convert multi format file to a readable ascii format | gaur.deepti | UNIX for Dummies Questions & Answers | 5 | 03-25-2008 03:03 PM |
| File Format issue: Output of sqlplus | deepakgang | UNIX for Dummies Questions & Answers | 2 | 10-25-2007 03:56 AM |
| Format the output of file | getdpg | Shell Programming and Scripting | 9 | 01-24-2006 12:50 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
format the output from a file
hi ,
i need to format the output which is availble in a file file output is Following are the Process_Scheduler Domains running in the server Ram-pc VPORCL Following are the Application Server domains running in the server Ram-pc VPORCL01 VPORCL02 these value VPORCL,VPORCL01... are dynamic value i need to print this out int his format hostname domaintype domain name Ram-pc Process_Scheduler VPORCL Ram-pc Application Server VPORCL01 Ram-pc Application Server VPORCL02 thanxs in advance |
|
||||
|
try out this..
Code:
NoOfWords=0
while read LINE
do
NoOfWords=`echo $LINE|wc -w|awk '{print $1}'`
#echo "NoOfWords : [$LINE][$NoOfWords]"
if [ "$NoOfWords" -eq "1" ]
then
echo "$OutString " " $LINE"
elif [ "$NoOfWords" -eq "10" ]
then
OutString=`echo $LINE|awk '{printf "%s %s", $10,$4}'`
elif [ "$NoOfWords" -eq "11" ]
then
OutString=`echo $LINE|awk '{printf "%s %s %s", $11,$4,$5}'`
fi
done < Filename
Note : instead of Filename, you have to give the input filename. |
|
|||||
|
Or...
Code:
awk -F '(Following are the |[dD]omains running in the server )' 'NF>1{x=$3 OFS $2}NF==1{print x $1}' file1
Code:
Ram-pc Process_Scheduler VPORCL Ram-pc Application Server VPORCL01 Ram-pc Application Server VPORCL02 |
|
||||
|
Code:
my($type,$name);
while(<DATA>){
if(/.*the\s+(.*)\s+[Dd]omains.*server\s+(.*)/){
$type=$1;
$name=$2;
next;
}
print $name," ",$type," ",$_;
}
__DATA__
Following are the Process_Scheduler Domains running in the server Ram-pc
VPORCL
Following are the Application Server domains running in the server Ram-pc
VPORCL01
VPORCL02
|
| Sponsored Links | ||
|
|