|
Search:
Advanced search
|
Browse by category:
|
Glossary | Contact Us |
Remove path from find result in Bash |
|||||
Find all .sh files from current directory.
$ find . -name "*.sh"
Now if we need to remove the path part from the above find command output: $ find . -name "*.sh" -exec basename {} \;
Same as $ find . -name "*.sh" | xargs -i basename {} And using sed: $ find . -name "*.sh" | sed 's!.*/!!' i.e. replace all characters until last / by nothing (here ! is used as the sed delimiter instead of the usual /) |
|||||
| Others in this Category | |
| Remove Empty Lines and Comments | |
| Lab Exam and sample solutions | |
| Detach a working copy from SVN or CVS | |
| Standard Input and Output Redirection | |
Powered by
KBPublisher (Knowledge base software)