- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Understanding Sed statement
Operating System - HP-UX
1822818
Members
4243
Online
109645
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
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
Discussion Boards
Discussion Boards
Discussion Boards
Blogs
Information
Community
Resources
Community Language
Language
Forums
Blogs
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
тАО06-08-2010 02:13 AM
тАО06-08-2010 02:13 AM
Understanding Sed statement
Hi,
I have found the following statement to list only subdirectories which are not empty.
find . -type f | sed "s%/[^/]*$%%" | sort -u
I don't really understand the sed statement. I know it cuts the filenames away at the end of each line that was found by "find -type f", but I would like to be able to understand how
the statement actually is built.
Is there anyone who is able to explain the sed-part ?
Regards,
Brecht
I have found the following statement to list only subdirectories which are not empty.
find . -type f | sed "s%/[^/]*$%%" | sort -u
I don't really understand the sed statement. I know it cuts the filenames away at the end of each line that was found by "find -type f", but I would like to be able to understand how
the statement actually is built.
Is there anyone who is able to explain the sed-part ?
Regards,
Brecht
- Tags:
- sed
2 REPLIES 2
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-08-2010 02:27 AM
тАО06-08-2010 02:27 AM
Re: Understanding Sed statement
"s" is "substitute".
"%" is a delimiter. Normally, people use
"/" for that, but that's inconvenient when
looking for a "/" (and "sed" lets you use any
character as a delimiter).
So, it's looking for a "/", followed by any
number of non-"/" characters ("[^/]*") at the
end of a line ("$"), and substituting nothing
(what's between "%" and "%" in "%%") for
that.
man sed
"%" is a delimiter. Normally, people use
"/" for that, but that's inconvenient when
looking for a "/" (and "sed" lets you use any
character as a delimiter).
So, it's looking for a "/", followed by any
number of non-"/" characters ("[^/]*") at the
end of a line ("$"), and substituting nothing
(what's between "%" and "%" in "%%") for
that.
man sed
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-08-2010 03:06 AM
тАО06-08-2010 03:06 AM
Re: Understanding Sed statement
Ok thanks for the explanation.
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
Learn About
News and Events
Support
© Copyright 2025 Hewlett Packard Enterprise Development LP