-   Linux - General (
-   -   using commands to output path, filename and info to a txt file (

bob_man_uk 05-11-2006 08:50 AM

using commands to output path, filename and info to a txt file
ok, this might be a bit difficult but here goes

I have a directory, say /file

in said directory there are aprox 20 files with the structure soXXXXXX.xml where XXXXXX is a number

what i need is to list all these files with their path and with XXXXXX right next to it

For Example

123456 /so123456.xml

Or better yet, seperate the two by pipe "|" and ending with a pipe


i can get the list of the files with find

find ./ -name "so*.xml" -print > list.txt

but that just gives ./so123456.xml,

i'd need to strip out the . at the start and then take the 123456 out of the line, which i havent got a clue how to do then add a | in the middle.

any ideas?

thanks in advance

Matty G

acid_kewpie 05-11-2006 09:37 AM


find ./ -name "so*.xml" | awk '{{sub(/^\./, "", $0); match($0, /so(.*)\.xml/, arr); print arr[1] "|" $0 "|"}'

bob_man_uk 05-11-2006 11:37 AM

and this is supposed to be run from the command line correct?

i get


awk: cmd. line:1: ^ unexpected newline or end of string
the unexpected newline is actually pointing at the 1

acid_kewpie 05-11-2006 03:31 PM

hmm... ok. well i tested it doing an "echo ./so12345.xml | awk ..." so i guess the find output is different. i'm sure you can tweak it ;-)

All times are GMT -5. The time now is 04:46 AM.