- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: script help
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-16-2002 07:55 AM
01-16-2002 07:55 AM
script help
I have a report that have 10 different kinds of data (i.e: data: CMTP
info about the data ....
....
....
data: MDCA
info about the data....
....
....)
and each data has various info that some can be 1 page or up to 3 pages long. So instead of have over 100 pages of report to see only 2 of the data info that is require - I'm writing a script to parse the info for the 2 types of data that are needed and send it to another file so that the user can print it if he/she wants. I had tried grep (but it only show the line where it matches not the info after that) I'd read that sed can do the trick. Can someone help me with this. Thank you.
Thi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-16-2002 08:24 AM
01-16-2002 08:24 AM
Re: script help
You can do something like this:
num=`grep -n "CMDAS" coco1| cut -d":" -f1`
echo $num
echo "$num,\$ w temp" |ed coco1
num2=`grep -n "DATA" temp| head -2 | tail -1 | cut -d":" -f1`
echo $num2
(( num2 = num2 -1 ))
echo "1,$num2 w temp" |ed temp
Regards,
Justo.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-16-2002 08:45 AM
01-16-2002 08:45 AM
Re: script help
sed -n -e '/^data: /,/.*)$/p'
-- Rod Hills
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-16-2002 09:01 AM
01-16-2002 09:01 AM
Re: script help
awk '/data: DATA/,/end/ { print $0 }' file.dat
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-16-2002 09:39 AM
01-16-2002 09:39 AM
Re: script help
#
$ReportFile = "/tmp/4";
#
open(REPORTLINES, "<".$ReportFile) || die "can not open $ReportFile";
#
LINE: while(
$lineofdata = $_;
if (substr($lineofdata,0,5) eq "Data:") {
$reportname = substr($lineofdata,6,length($lineofdata)-6);
$ReportFileName=$ReportFile . $reportname;
close(NEWREPORT);
open(NEWREPORT, ">".$ReportFileName) || die "can not open $ReportFile$repo
rtname";
next LINE;
}
#
printf NEWREPORT $lineofdata;
}
close(REPORTFIXED);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-16-2002 12:34 PM
01-16-2002 12:34 PM
Re: script help
list="CTMT GRPP MDDA"
for file in $list
do
awk '/DATA: $file/,/Report/ {print $0}'
done
This will allow me to go through loop and print 3 types of data and append it to a newfile. However, when I ran this sript the variable $file did not get pass to the awk command line at all. The error report from awk is:
awk: There is a regular expression error.
Invalid pattern.
The input line number is 1.
The source line number is 1.
Is there a way to pass a variable to the awk command in a script ? Again thank you for your help.
Thi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-16-2002 12:49 PM
01-16-2002 12:49 PM
Re: script help
awk '/DATA: $file/,/Report/ {print $0}'
to
awk -Ffile="DATA: $file" 'file,/Report/ {print $0}' ...
The -F option sets awk variable "file" to "DATA: $file" and then you can use that awk variable in your awk script.
-- Rod Hills
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-16-2002 12:50 PM
01-16-2002 12:50 PM
Re: script help
-- Rod Hills
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-16-2002 01:08 PM
01-16-2002 01:08 PM
Re: script help
Try this:
# file=/tmp/myfile
# echo awk '$0~DATA: file,/Report/ {print $0}' file=$file
Regards!
...JRF...