- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: sed command 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
03-15-2004 03:35 AM
03-15-2004 03:35 AM
Why does this command work?
sed 's/\(TAPES\:.*\) \(FILES\:.*\)/{s/ 0/
0//}g'
Data Before:
DATE: MAR 03 2004 CLASS: UX_PROD TAPES: 030043 030260 030233 030237 FILES: /oracle* /oracle1* /oracle2*
DATE: MAR 04 2004 CLASS: UX_PROD_OTHER TAPES: 030127 FILES: /sybdump
What I am trying to do DATA AFTER:
DATE: MAR 03 2004 CLASS: UX_PROD TAPES:
030043
030260
030233
030237 FILES: /oracle* /oracle1* /oracle2*
DATE: MAR 04 2004 CLASS: UX_PROD_OTHER TAPES:
030127 FILES: /sybdump
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-15-2004 04:20 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-15-2004 04:26 AM
03-15-2004 04:26 AM
Re: sed command help!!!
This uses awk rather than sed, but gets the result you wanted.
I've created 2 files. The input file is test.in and contains the following :-
DATE: MAR 03 2004 CLASS: UX_PROD TAPES: 030043 030260 030233 030237 FILES:
/oracle* /oracle1* /oracle2*
DATE: MAR 04 2004 CLASS: UX_PROD_OTHER TAPES: 030127 FILES: /sybdump
test.ksh contains :-
cat ./test.in | awk -F" " ' \
BEGIN {}
/UX_PROD TAPES/ {print $1" "$2" "$3" "$4" "$5" "$6" "$7"
"$8"
"$9"
"$10"
"$11" "$12" "$13" "$14" "$15}
/UX_PROD_OTHER TAPES/ {print $1" "$2" "$3" "$4" "$5" "$6" "$7"
"$8" "$9"
"$10" "$11" "$12" "$13" "$14" "$15}'
Run ksh ./test.ksh and the output is as you wanted :-
DATE: MAR 03 2004 CLASS: UX_PROD TAPES:
030043
030260
030233
030237 FILES: /oracle* /oracle1* /oracle2*
DATE: MAR 04 2004 CLASS: UX_PROD_OTHER TAPES:
030127 FILES: /sybdump
Regards,
Dave.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-15-2004 04:30 AM
03-15-2004 04:30 AM
Re: sed command help!!!
perl -ne '($s,$m,$e)=(/(.+TAPES:)(.+)(FILES.+)/);$m=~s/ /
/g;print "${s}${m}${e}\n"'
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-15-2004 06:19 AM
03-15-2004 06:19 AM
Re: sed command help!!!
Your awk works great!! But how can I make it so the
is after the numbers not before as I showed incorrectly.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-15-2004 06:44 AM
03-15-2004 06:44 AM
Re: sed command help!!!
Never mind I got it.
awk '
{
flg=0;
n1=split($0,tab);
for(i=1; i <= n1;i++) {
if(tab[i]=="FILES:") flg=0;
if(flg==2) printf("
");
if(flg==1) flg=2;
printf("%s ",tab[i]);
if(tab[i]=="TAPES:") flg=1;
}
printf("\n");
}' $INPUT.tmp3 > $INPUT.tmp2
THANKS ALOT!!!
And Thanks to all who answered.