| Author |
doubt with this shell script unix command
|
preethi kumar
Ranch Hand
Joined: Jun 04, 2010
Posts: 50
|
|
find . -name "*" -type f gives me the below output
./test3.php
./test2.php
./test1.php
i want to pipe some command in such a way that my output should be
test3.php
test2.php
test1.php
and the number of php files and lines can change. so how do i write a general linux command?
|
 |
Jeanne Boyarsky
internet detective
Marshal
Joined: May 26, 2003
Posts: 26144
|
|
There are a number of ways to do this. The one I think of is to use sed to remove the first two characters from each line:
find . -name "*" -type f | sed 's/^..//'
|
[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
|
 |
Stefan Wagner
Ranch Hand
Joined: Jun 02, 2003
Posts: 1923
|
|
This works for gnu-find. Your find might differ.
Instead of piping, it is often, but not always, a good idea, to use one of the switches: -exec, -execdir, -ok, -okdir. It isn't trivial to use, but powerful.
|
http://home.arcor.de/hirnstrom/bewerbung
|
 |
preethi kumar
Ranch Hand
Joined: Jun 04, 2010
Posts: 50
|
|
|
Thank you guys. your response really helped .
|
 |
 |
|
|
subject: doubt with this shell script unix command
|
|
|