HPE GreenLake Administration
- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Complex grep command
Operating System - HP-UX
1827862
Members
2166
Online
109969
Solutions
Forums
Categories
Company
Local Language
back
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
back
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
Blogs
Information
Community
Resources
Community Language
Language
Forums
Blogs
Go to solution
Topic Options
- 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
09-04-2007 06:39 PM
09-04-2007 06:39 PM
Hello.
Could you please help me in understanding what below commands would do - I get lost somewhere:
1)
grep -q $prebase `awk '{ if (/DB\.pf/)
{ ncol=split($2,tab,"/"); printf("%s ",tab[ncol]) } }' *SV.pf`
2)
probkup $base $OPTION /dev/null -estimate -vs $vol_size|
awk -v nombkup=$ARCH_BKUP/$nombkup '{
if (/volumes are req/) nbvol=10}
END { for(i=1;i printf("%s.%d.bkp\n",nombkup,1+i) }' > $ARCH_BKUP/VOL.BKP
NBVOL=`awk 'END { print NR+1 }' $ARCH_BKUP/VOL.BKP`
Thank you!
Could you please help me in understanding what below commands would do - I get lost somewhere:
1)
grep -q $prebase `awk '{ if (/DB\.pf/)
{ ncol=split($2,tab,"/"); printf("%s ",tab[ncol]) } }' *SV.pf`
2)
probkup $base $OPTION /dev/null -estimate -vs $vol_size|
awk -v nombkup=$ARCH_BKUP/$nombkup '{
if (/volumes are req/) nbvol=10}
END { for(i=1;i
NBVOL=`awk 'END { print NR+1 }' $ARCH_BKUP/VOL.BKP`
Thank you!
Solved! Go to Solution.
3 REPLIES 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-04-2007 08:16 PM
09-04-2007 08:16 PM
Re: Complex grep command
Hi,
1) part1:
awk '{ if (/DB\.pf/) ... ' *SV.pf
Examines files *SV.pf for lines containing 'DB.pf'.
part2:
ncol=split($2,tab,"/"); printf("%s ",tab[ncol])
Takes the second field, which seems to be a pathname, extracts and prints the pure base filename.
part3: grep -q $prebase ``
Sets just a return value if $prebase is found in the above printed filenames
2 (which is not a grep and seems not really reasonable to me :-)
part1:
Analyses the output of the commamd 'probkup',
if it contains the string 'volumes are req'.
part2:
If that is true, 9 lines are printed to a file of the format (variables expanded)
$ARCH_BKUP/$nombkup.2.bkp
...
$ARCH_BKUP/$nombkup.10.bkp
part3:
Variable NBVOL is set to the number of lines of this file +1.
The result will be 1 (no match in part1) or 10 (any number of matches in part1).
mfG Peter
1) part1:
awk '{ if (/DB\.pf/) ... ' *SV.pf
Examines files *SV.pf for lines containing 'DB.pf'.
part2:
ncol=split($2,tab,"/"); printf("%s ",tab[ncol])
Takes the second field, which seems to be a pathname, extracts and prints the pure base filename.
part3: grep -q $prebase ``
Sets just a return value if $prebase is found in the above printed filenames
2 (which is not a grep and seems not really reasonable to me :-)
part1:
Analyses the output of the commamd 'probkup',
if it contains the string 'volumes are req'.
part2:
If that is true, 9 lines are printed to a file of the format (variables expanded)
$ARCH_BKUP/$nombkup.2.bkp
...
$ARCH_BKUP/$nombkup.10.bkp
part3:
Variable NBVOL is set to the number of lines of this file +1.
The result will be 1 (no match in part1) or 10 (any number of matches in part1).
mfG Peter
The Universe is a pretty big place,
it's bigger than anything anyone has ever dreamed of before.
So if it's just us, seems like an awful waste of space, right?
Jodie Foster in "Contact"
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-04-2007 09:21 PM
09-04-2007 09:21 PM
Re: Complex grep command
Hello.
Could you also please help me in understanding below command :
if ! tar xf $SOURCE `tar tf $SOURCE | grep '^ipasii'`
then
echo "not success"
fi
Thank you!
Could you also please help me in understanding below command :
if ! tar xf $SOURCE `tar tf $SOURCE | grep '^ipasii'`
then
echo "not success"
fi
Thank you!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-04-2007 10:27 PM
09-04-2007 10:27 PM
Solution
Hi,
regarding your tar:
part1) .. `tar tf ... | grep '^..'`
The command in the backtics lists the content of $ARCHIVE and filters out filenames starting with 'ipasii'
part2) tar xf ``
The above filename are fed into tar for restore
part3) if ! tar
If the tar failes, an error message is echoed.
CAUTION:
There will be no message or error reported, when NO name of the form of part1 is found in the tar archive: Having write access to the target, all files of the archive would be extracted!
I don't think, the writer of this piece of code intended this to do ...
mfG Peter
regarding your tar:
part1) .. `tar tf ... | grep '^..'`
The command in the backtics lists the content of $ARCHIVE and filters out filenames starting with 'ipasii'
part2) tar xf ``
The above filename are fed into tar for restore
part3) if ! tar
If the tar failes, an error message is echoed.
CAUTION:
There will be no message or error reported, when NO name of the form of part1 is found in the tar archive: Having write access to the target, all files of the archive would be extracted!
I don't think, the writer of this piece of code intended this to do ...
mfG Peter
The Universe is a pretty big place,
it's bigger than anything anyone has ever dreamed of before.
So if it's just us, seems like an awful waste of space, right?
Jodie Foster in "Contact"
The opinions expressed above are the personal opinions of the authors, not of Hewlett Packard Enterprise. By using this site, you accept the Terms of Use and Rules of Participation.
Company
Support
Events and news
Customer resources
© Copyright 2025 Hewlett Packard Enterprise Development LP