• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

doubt with this shell script unix command

 
preethi kumar
Ranch Hand
Posts: 50
  • 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: 34656
366
Eclipse IDE Java VI Editor
  • 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
  • Likes 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
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you guys. your response really helped .
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic