0

I am trying to write a simple bash script that will search for files with a certain extension in a directory. Then output all those files with full path in front.

For example, if I have a directory with many different file types, but I want to know the information about those with only the .txt extension. How can I get the output in a new file to look similar to this:

/home/jason/code/test1.txt
/home/jason/code/test2.txt
.
.
.

All I have right now is this, which is not really what I am trying to do, but it is just my attempt at experimentation because I am new:

ls *.txt >prog_list.txt
pwd >pwd.txt
cat pwd.txt prog_list.txt > prog_dir.txt
unutbu
  • 777,569
  • 165
  • 1,697
  • 1,613
newbie_dev
  • 57
  • 1
  • 6
  • asked a different way, but a nearly a dupe of this: http://stackoverflow.com/questions/246215/how-can-i-list-files-with-their-absolute-path-in-linux – hometoast Jul 30 '10 at 19:26

4 Answers4

2
find /home/jason/code -iname "*.txt" > prog_dir.txt
Amardeep AC9MF
  • 17,715
  • 5
  • 39
  • 50
1

find ~/code -name '*.txt'

Daenyth
  • 33,666
  • 12
  • 82
  • 120
1
$>find -name "*.yourext" > myFile.txt

For more information on the find command, type:

$>man find
naikus
  • 23,937
  • 4
  • 41
  • 43
0

Would something like:


find . -name *.txt -print

do the trick?

Kiersten Arnold
  • 1,790
  • 1
  • 12
  • 17