aspose file tools*
The moose likes Linux / UNIX and the fly likes doubt with this shell script unix command Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Engineering » Linux / UNIX
Bookmark "doubt with this shell script unix command" Watch "doubt with this shell script unix command" New topic
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
author & internet detective
Marshal

Joined: May 26, 2003
Posts: 30764
    
156

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 .
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: doubt with this shell script unix command