File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

doubt with this shell script unix command

 
preethi kumar
Ranch Hand
Posts: 50
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 33697
316
Eclipse IDE Java VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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/^..//'
 
Stefan Wagner
Ranch Hand
Posts: 1923
Linux Postgres Database Scala
  • 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


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.
 
preethi kumar
Ranch Hand
Posts: 50
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you guys. your response really helped .
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic