[lug] Displaying a list of files

Jeff Schroeder jeff at neobox.net
Thu Dec 12 11:26:19 MST 2002


I have a shell script that collects a list of files with potential 
problems in them, and displays the list to the user as part of an 
installation process.  I'm storing the list in a shell variable, like 
so:

list=`find -type f -exec grep -li "problem code" {} \;`

but when I try to echo it to the user I get a space-delimited list:

path/file1.php path/file2.php path/file3.php

What I'd prefer (for readability) is a newline-delimited list:

path/file1.php
path/file2.php
path/file3.php

I tried using sed to substitute newlines for spaces, but it doesn't work 
at all:

echo $list | sed s/" "/"^M"/g

Does anyone know how to make a space-for-newline substitution inline 
like that?  sed doesn't seem to be the answer; awk can probably do it 
but I don't know enough awk to make it work.

TIA,
Jeff



More information about the LUG mailing list