LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   grep question (https://www.linuxquestions.org/questions/linux-newbie-8/grep-question-674227/)

torrent478 10-04-2008 12:37 PM

grep question
 
or at least I think its grep I need to be using...

I need to get a list of all the absolute pathways of every file in a single folder (300+ files) and have them piped into a text document.

I've done it before but its been a really long time and I have no idea what to do anymore :'(

If anyone has any ideas it would be greatly appreciated!


Thanks =)

anomie 10-04-2008 01:24 PM

How about simply:
$ find /path/here

Redirect stdout from that into your text file...

Savet 10-08-2008 06:50 PM

If I understand your need, you want to list the entire contents of a directory, and pipe that into a text file.

since ls will only display the filenames, you can get the directory via the pwd command. Unless you absolutely need the path to preceed the filenames, I'll assume that simply listing the path at the beginning of the file is sufficient...in which case, the following commands should get you what you need:

Code:

pwd > /path/to/output_file && ls -ld * >> /path/to/output_file
The above assumes that you are running it from the directory you wish to list the contents of.

If I've misunderstood, and you have a bunch of symbolic links in said directory, and you're wanting to see where you're linking to...the following should do the trick:

Code:

ls -ld * |grep '>' > /path/to/output_file


All times are GMT -5. The time now is 07:26 AM.