[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[no subject]



Whoever allowed blanks to be part of dirnames and filenames should be
strung up by the thumbs.  (Are you listening, Billy?)

These abominations can be dealt with in scripts by very careful use
of quotes.  Here's an example.  Put this data into /tmp/filelist:

/dir/bad dir/file.txt
/dir2/dir3/bad file.txt
/dir1/bad dir/bad file.txt

and this script into /tmp/split:   (be sure to make it executable)

while read line ; do
    DIR=`dirname "$line"`
    FILE=`basename "$line"`
    echo "$line ->  DIR: $DIR      FILE: $FILE"
done < /tmp/filelist


Then run /tmp/split to get this output:

$ /tmp/split
/dir/bad dir/file.txt ->  DIR: /dir/bad dir      FILE: file.txt
/dir2/dir3/bad file.txt ->  DIR: /dir2/dir3      FILE: bad file.txt
/dir1/bad dir/bad file.txt ->  DIR: /dir1/bad dir      FILE: bad file.txt


Note that dirname and basename have correctly parsed the contents of
"$line" because it's quoted.

Not one line.  Sorry.  But maybe you'll get some insight.

-- 
	David A. De Graaf    DATIX, Inc.    Hendersonville, NC
	dad at datix.2y.net     www.datix.us


</pre>
<!--X-Body-of-Message-End-->
<!--X-MsgBody-End-->
<!--X-Follow-Ups-->
<hr>
<!--X-Follow-Ups-End-->
<!--X-References-->
<ul><li><strong>References</strong>:
<ul>
<li><strong><a name="00533" href="msg00533.html">[ale] Looking for a one line script</a></strong>
<ul><li><em>From:</em> james.sumners at gmail.com (James Sumners)</li></ul></li>
</ul></li></ul>
<!--X-References-End-->
<!--X-BotPNI-->
<ul>
<li>Prev by Date:
<strong><a href="msg00535.html">[ale] Looking for a one line script</a></strong>
</li>
<li>Next by Date:
<strong><a href="msg00537.html">[ale] Looking for a one line script</a></strong>
</li>
<li>Previous by thread:
<strong><a href="msg00535.html">[ale] Looking for a one line script</a></strong>
</li>
<li>Next by thread:
<strong><a href="msg00537.html">[ale] Looking for a one line script</a></strong>
</li>
<li>Index(es):
<ul>
<li><a href="maillist.html#00536"><strong>Date</strong></a></li>
<li><a href="threads.html#00536"><strong>Thread</strong></a></li>
</ul>
</li>
</ul>

<!--X-BotPNI-End-->
<!--X-User-Footer-->
<!--X-User-Footer-End-->
</body>
</html>