- 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
Discussions
Discussions
Forums
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
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-02-2001 07:05 AM
тАО01-02-2001 07:05 AM
I want to parse a text file for a particular line - then when found read the
following lines until another line found
ie
find this line PV Name LE on PV PE on PV
push these to a new file /dev/dsk/c2t4d0 2048 2048
finsh here --- Logical extents ---
Hope someone can help
Thanks
Keith
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-02-2001 07:11 AM
тАО01-02-2001 07:11 AM
Re: script help...
AGREP is the best tool for you.
The main difference with grep, is that agrep has definabla record delimiters (could be a string) while grep only has the End-Of-line.
You'll find it at the porting center:
http://hpux.cae.wisc.edu/hppd/hpux/Misc/agrep-2.04/
Best regards,
Dan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-02-2001 07:12 AM
тАО01-02-2001 07:12 AM
Re: script help...
Here is the small abstract for agrep:
Searches text for strings or approximations thereof. Agrep is similar to the standard UNIX grep utility, but is more general, and according to its authors, usually faster. Its most notable feature is the approximate pattern matching facility. Agrep has other features not found in the grep family: It is record rather than line orientated; pattern matches can be output in a larger context than a single line. Multiple search patterns can be specified with AND/OR logic.
Dan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-02-2001 07:14 AM
- Tags:
- awk
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-02-2001 07:25 AM
тАО01-02-2001 07:25 AM
Re: script help...
awk ' /PV Name/ {
getline;
while ( $0 !~ "Logical extends" ) {
print $0;
getline;
}
exit;
}'
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-02-2001 07:26 AM
тАО01-02-2001 07:26 AM
Re: script help...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-02-2001 07:42 AM
тАО01-02-2001 07:42 AM
Re: script help...
cat FILE | awk '/PV Name LE/,/Logical extents/' > NEW_FILE
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-02-2001 08:28 AM
тАО01-02-2001 08:28 AM
Re: script help...
#!/usr/bin/ksh
string1=$1
string2=$2
awk ' {
if ( $0 ~ "'"$string1"'" ) {
getline;
while ( $0 !~ "'"$string2"'" ) {
# remove blanklines
if ( $0 !~ /^$/ ) print $0;
getline;
}
exit;
}
}'
then use it where ever you like
lvdisplay | print_from_s1_to_s2 "PV Name" "Logical extents" > yourfile
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-02-2001 09:17 AM
тАО01-02-2001 09:17 AM
Re: script help...
At least one works - I will check the various methods - and assign points -
Again thanks for all your help
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-04-2001 10:46 AM
тАО01-04-2001 10:46 AM
Re: script help...
lvdisplay -v /dev/vg00/lvol1 | sed -n "/-- Distribution/,/^$/p"
is close to what you want.
This is a sed(1) "ranging". The first /RE/ instructs sed(1) to find the line with the RE (where RE is a regular expression). The second /RE/, /^$/ is looking for a blank line that follows the first RE. 'p' prints lines (that is why sed(1) was called with -n, don't print unless I tell you to).
Now, using sed(1), lets strip out what you don't want:
lvdisplay...| sed -n "/--Distribution/,/^$/{
/--Distribution/d
/PV Name/d
/^$/d
p
}"
The stuff between the curly braces is a subroutine. The statements delete what you don't want (including the trailing blank line) and explicity print what remains.
Enjoy,
-dlt-