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
08-19-2004 06:51 AM
08-19-2004 06:51 AM
I have 2 sed commands that seem to work but I can't combine them.
These outputs are all I want. How Can I combine them ?
# sed -n '/sgmsg[1a][0-2]\.txt/p' file.list
-rwx------ 1 BUILTIN OHIO-OMNI_MMSR 56 Aug 18 09:30 sgmsg10.txt
-rwx------ 1 BUILTIN OHIO-OMNI_MMSR 56 Aug 18 09:36 sgmsg11.txt
-rwx------ 1 BUILTIN OHIO-OMNI_MMSR 56 Aug 18 09:41 sgmsg12.txt
-rwx------ 1 BUILTIN OHIO-OMNI_MMSR 56 Aug 18 09:41 sgmsga2.txt
# sed -n '/sgmsg[3-9].txt/p' file.list
-rwx------ 1 BUILTIN OHIO-OMNI_MMSR 54 Aug 18 09:08 sgmsg5.txt
-rwx------ 1 BUILTIN OHIO-OMNI_MMSR 54 Aug 18 09:08 sgmsg3.txt
-rwx------ 1 BUILTIN OHIO-OMNI_MMSR 54 Aug 18 09:03 sgmsg6.txt
-rwx------ 1 BUILTIN OHIO-OMNI_MMSR 54 Aug 18 09:13 sgmsg7.txt
-rwx------ 1 BUILTIN OHIO-OMNI_MMSR 54 Aug 18 09:18 sgmsg8.txt
-rwx------ 1 BUILTIN OHIO-OMNI_MMSR 54 Aug 18 09:23 sgmsg9.txt
I get this when I try.
# sed -n '/sgmsg[0-9].txt/,/sgmsg[1a][0-2]\.txt/p' file.list
-rwx------ 1 BUILTIN OHIO-OMNI_MMSR 54 Aug 18 09:08 sgmsg5.txt
-rwx------ 1 BUILTIN OHIO-OMNI_MMSR 54 Aug 18 09:08 sgmsg1.txt
-rwx------ 1 BUILTIN OHIO-OMNI_MMSR 54 Aug 18 09:08 sgmsg2.txt
-rwx------ 1 BUILTIN OHIO-OMNI_MMSR 54 Aug 18 09:08 sgmsg3.txt
-rwx------ 1 BUILTIN OHIO-OMNI_MMSR 54 Aug 18 09:03 sgmsg6.DUH
-rwx------ 1 BUILTIN OHIO-OMNI_MMSR 54 Aug 18 09:03 sgmsg6.txt
-rwx------ 1 BUILTIN OHIO-OMNI_MMSR 54 Aug 18 09:13 sgmsg7.txt
-rwx------ 1 BUILTIN OHIO-OMNI_MMSR 54 Aug 18 09:18 sgmsg8.txt
-rwx------ 1 BUILTIN OHIO-OMNI_MMSR 54 Aug 18 09:23 sgmsg901.txt
-rwx------ 1 BUILTIN OHIO-OMNI_MMSR 54 Aug 18 09:23 sgmsg9.txt
-rwx------ 1 BUILTIN OHIO-OMNI_MMSR 61 Aug 17 18:14 sgmsgOMNA2.txt
-rwx------ 1 BUILTIN OHIO-OMNI_MMSR 61 Aug 17 18:14 sgmsgomna2.txt
Here is my file.list
# cat file.list
drwx------ 1 BUILTIN OHIO-OMNI_MMSR 0 Aug 18 09:40 .
drwx------ 1 BUILTIN OHIO-OMNI_MMSR 0 Aug 18 09:40 ..
-rwx------ 1 BUILTIN OHIO-OMNI_MMSR 56 Aug 18 09:30 sgmsg10.txt
-rwx------ 1 BUILTIN OHIO-OMNI_MMSR 56 Aug 18 09:30 sgmsg.txt
-rwx------ 1 BUILTIN OHIO-OMNI_MMSR 56 Aug 18 09:30 SGMSG10.TXT
-rwx------ 1 BUILTIN OHIO-OMNI_MMSR 56 Aug 18 09:36 sgmsg11.txt
-rwx------ 1 BUILTIN OHIO-OMNI_MMSR 56 Aug 18 09:41 sgmsg12.txt
-rwx------ 1 BUILTIN OHIO-OMNI_MMSR 56 Aug 18 09:41 sgmsga2.txt
-rwx------ 1 BUILTIN OHIO-OMNI_MMSR 56 Aug 18 09:41 sgmsgaa.txt
-rwx------ 1 BUILTIN OHIO-OMNI_MMSR 54 Aug 18 09:08 sgmsg5.txt
-rwx------ 1 BUILTIN OHIO-OMNI_MMSR 54 Aug 18 09:08 sgmsg1.txt
-rwx------ 1 BUILTIN OHIO-OMNI_MMSR 54 Aug 18 09:08 sgmsg2.txt
-rwx------ 1 BUILTIN OHIO-OMNI_MMSR 54 Aug 18 09:08 sgmsg3.txt
-rwx------ 1 BUILTIN OHIO-OMNI_MMSR 54 Aug 18 09:03 sgmsg6.DUH
-rwx------ 1 BUILTIN OHIO-OMNI_MMSR 54 Aug 18 09:03 sgmsg6.txt
-rwx------ 1 BUILTIN OHIO-OMNI_MMSR 54 Aug 18 09:13 sgmsg7.txt
-rwx------ 1 BUILTIN OHIO-OMNI_MMSR 54 Aug 18 09:18 sgmsg8.txt
-rwx------ 1 BUILTIN OHIO-OMNI_MMSR 54 Aug 18 09:23 sgmsg901.txt
-rwx------ 1 BUILTIN OHIO-OMNI_MMSR 54 Aug 18 09:23 sgmsg9.txt
-rwx------ 1 BUILTIN OHIO-OMNI_MMSR 61 Aug 17 18:14 sgmsgOMNA2.txt
-rwx------ 1 BUILTIN OHIO-OMNI_MMSR 61 Aug 17 18:14 sgmsgomna2.txt
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-19-2004 07:56 AM
08-19-2004 07:56 AM
SolutionOne way to do it is to use the '-e' option to specify the separate scripts. I tried it this way and got it to work:
>sed -n -e '/sgmsg[1a][0-2]\.txt/p' -e '/sgmsg[3-9].txt/p' file.list
-rwx------ 1 BUILTIN OHIO-OMNI_MMSR 56 Aug 18 09:30 sgmsg10.txt
-rwx------ 1 BUILTIN OHIO-OMNI_MMSR 56 Aug 18 09:36 sgmsg11.txt
-rwx------ 1 BUILTIN OHIO-OMNI_MMSR 56 Aug 18 09:41 sgmsg12.txt
-rwx------ 1 BUILTIN OHIO-OMNI_MMSR 56 Aug 18 09:41 sgmsga2.txt
-rwx------ 1 BUILTIN OHIO-OMNI_MMSR 54 Aug 18 09:08 sgmsg5.txt
-rwx------ 1 BUILTIN OHIO-OMNI_MMSR 54 Aug 18 09:08 sgmsg3.txt
-rwx------ 1 BUILTIN OHIO-OMNI_MMSR 54 Aug 18 09:03 sgmsg6.txt
-rwx------ 1 BUILTIN OHIO-OMNI_MMSR 54 Aug 18 09:13 sgmsg7.txt
-rwx------ 1 BUILTIN OHIO-OMNI_MMSR 54 Aug 18 09:18 sgmsg8.txt
-rwx------ 1 BUILTIN OHIO-OMNI_MMSR 54 Aug 18 09:23 sgmsg9.txt
JP
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-19-2004 08:11 AM
08-19-2004 08:11 AM
Re: sed help
But why to complicate the things ? how about egrep ?
egrep "sgmsg[1a3-9][0-2]*\.txt"
This will do exactly the same thing as your complicated lengthy sed
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-19-2004 08:21 AM
08-19-2004 08:21 AM
Re: sed help
The egrep gives me more than I want.
egrep "sgmsg[1a3-9][0-2]*\.txt" file.list
-rwx------ 1 BUILTIN OHIO-OMNI_MMSR 56 Aug 18 09:30 sgmsg10.txt
-rwx------ 1 BUILTIN OHIO-OMNI_MMSR 56 Aug 18 09:36 sgmsg11.txt
-rwx------ 1 BUILTIN OHIO-OMNI_MMSR 56 Aug 18 09:41 sgmsg12.txt
-rwx------ 1 BUILTIN OHIO-OMNI_MMSR 56 Aug 18 09:41 sgmsga2.txt
-rwx------ 1 BUILTIN OHIO-OMNI_MMSR 54 Aug 18 09:08 sgmsg5.txt
-rwx------ 1 BUILTIN OHIO-OMNI_MMSR 54 Aug 18 09:08 sgmsg1.txt NOT
-rwx------ 1 BUILTIN OHIO-OMNI_MMSR 54 Aug 18 09:08 sgmsg3.txt
-rwx------ 1 BUILTIN OHIO-OMNI_MMSR 54 Aug 18 09:03 sgmsg6.txt
-rwx------ 1 BUILTIN OHIO-OMNI_MMSR 54 Aug 18 09:13 sgmsg7.txt
-rwx------ 1 BUILTIN OHIO-OMNI_MMSR 54 Aug 18 09:18 sgmsg8.txt
-rwx------ 1 BUILTIN OHIO-OMNI_MMSR 54 Aug 18 09:23 sgmsg901.txt NOT
-rwx------ 1 BUILTIN OHIO-OMNI_MMSR 54 Aug 18 09:23 sgmsg9.txt
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-19-2004 08:26 AM
08-19-2004 08:26 AM
Re: sed help
egrep "sgmsg[1a3-9][0-2]*\.txt$" file.list
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-19-2004 08:27 AM
08-19-2004 08:27 AM
Re: sed help
Good point. I was able to get 'egrep' to work using the -e options also. The trick is that the expression doesn't need the '*' or else it will match too much. This seems to work:
> egrep -e "sgmsg[1a][0-2].txt" -e "sgmsg[3-9].txt" file.list
-rwx------ 1 BUILTIN OHIO-OMNI_MMSR 56 Aug 18 09:30 sgmsg10.txt
-rwx------ 1 BUILTIN OHIO-OMNI_MMSR 56 Aug 18 09:36 sgmsg11.txt
-rwx------ 1 BUILTIN OHIO-OMNI_MMSR 56 Aug 18 09:41 sgmsg12.txt
-rwx------ 1 BUILTIN OHIO-OMNI_MMSR 56 Aug 18 09:41 sgmsga2.txt
-rwx------ 1 BUILTIN OHIO-OMNI_MMSR 54 Aug 18 09:08 sgmsg5.txt
-rwx------ 1 BUILTIN OHIO-OMNI_MMSR 54 Aug 18 09:08 sgmsg3.txt
-rwx------ 1 BUILTIN OHIO-OMNI_MMSR 54 Aug 18 09:03 sgmsg6.txt
-rwx------ 1 BUILTIN OHIO-OMNI_MMSR 54 Aug 18 09:13 sgmsg7.txt
-rwx------ 1 BUILTIN OHIO-OMNI_MMSR 54 Aug 18 09:18 sgmsg8.txt
-rwx------ 1 BUILTIN OHIO-OMNI_MMSR 54 Aug 18 09:23 sgmsg9.txt
JP
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-19-2004 08:55 AM
08-19-2004 08:55 AM
Re: sed help
Yes you are right. * will pick up lot of things. But the above egrep is tailered for the above input :-)
The ? after the expression will eliminate the need for -e and mulitple expressions.
egrep "sgmsg[1a3-9][0-2]?\.txt$" file.list
Sundar.