- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: sed '/<regexp>/,//p where <regexp> contains "/...
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
07-21-2010 01:31 PM
07-21-2010 01:31 PM
Here is my test script:
# cat ./x
ls > x.tmp1
ls -d `pwd`/* > x.tmp2
echo "grep tcpdump x.tmp1"
grep tcpdump x.tmp1
echo "\ngrep tcpdump x.tmp2"
grep tcpdump x.tmp2
echo ""
set -v
sed -n "/tcpdump/,//p" x.tmp1
echo ""
sed -n "?/home/x40894/tcpdump?,??p" x.tmp2
And here is the output:
root@(pacsarch) [/home/x40894]
# ./x
grep tcpdump x.tmp1
tcpdump
grep tcpdump x.tmp2
/home/x40894/tcpdump
sed -n "/tcpdump/,//p" x.tmp1
tcpdump
trimfile.sh
unmount_archives.sh
vgpaths
x
x.tmp
x.tmp1
x.tmp2
xx
xxx
yy
yyy
echo ""
sed -n "?/home/x40894/tcpdump?,??p" x.tmp2
sed: ?/home/x40894/tcpdump?,??p is not a
recognized function.
As you can see, I can't get the sed command to parse correctly if the delimiter is not "/".
I've tried every variation I can think of, and I've tried various patterns of "\" escapes with no luck either.
????
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-21-2010 02:02 PM
07-21-2010 02:02 PM
Re: sed '/<regexp>/,//p where <regexp> contains "/"
# X="/tmp/some/path/and/file"
First with a "toothpick" syndrome:
# echo $X|sed -e 's/\//_/pg'
_tmp_some_path_and_file
Now, more readable with a '?' as a delimiter:
# echo $X|sed -e 's?/?_?pg'
_tmp_some_path_and_file
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-22-2010 08:05 AM
07-22-2010 08:05 AM
Re: sed '/<regexp>/,//p where <regexp> contains "/"
Thanks for your speedy reply. Unfortunately, it didn't exactly solve my problem, but it did point me to a workaround:
sed -n -e 's?/?~?g' -e '/~home~x40894~tcpdump/,//p' x.tmp2 | sed -e 's?~?/?g'
/home/x40894/tcpdump
/home/x40894/trimfile.sh
/home/x40894/unmount_archives.sh
/home/x40894/vgpaths
/home/x40894/x
/home/x40894/x.tmp
/home/x40894/x.tmp1
/home/x40894/x.tmp2
/home/x40894/xx
/home/x40894/xxx
/home/x40894/yy
/home/x40894/yyy
I'm not really pleased with having two executions of sed, but
sed -n -e 's?/?~?g' -e '/~home~x40894~tcpdump/,//p' -e 's?~?/?g' x.tmp2
~home~x40894~tcpdump
~home~x40894~trimfile.sh
~home~x40894~unmount_archives.sh
~home~x40894~vgpaths
~home~x40894~x
~home~x40894~x.tmp
~home~x40894~x.tmp1
~home~x40894~x.tmp2
~home~x40894~xx
~home~x40894~xxx
~home~x40894~yy
~home~x40894~yyy
doesn't do what I thought.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-22-2010 12:31 PM
07-22-2010 12:31 PM
Solution> I'm trying to generate a list of entries from a specific filename to the end of file
If that's the basic question, then delimiters aside:
# cat myfile
alpha
bravo
charlie
delta
echo
foxtrot
golf
# sed -n '/delta/,$p' myfile
delta
echo
foxtrot
golf
...or:
# cat myfile2
/home/alpha/1
/home/bravo/2
/home/charlie/3
/home/delta/4
/home/echo/5
/home/foxtrot/6
/home/golf/7
# sed -n '/\/home\/delta\/4/,$p'
...compared to:
# sed -n '/\/home\/delta\/3/,$p'
...which yields nothing because there is no starting match in the range to print. The '$' denotes the end-of-file.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-04-2010 04:13 PM
08-04-2010 04:13 PM
Re: sed '/<regexp>/,//p where <regexp> contains "/"
I haven't been able to get back to this for a while.
Your method of escaping the '/' chars in the
THX.