Bash Pitfalls

From mywiki.wooledge.org

This page shows common errors that Bash programmers make. The following examples are all flawed in some way:

???Contents
for i in `ls *.mp3`
cp $file $target
Filenames with leading dashes
[ $foo = “bar” ]
cd `dirname “$f”`
[ “$foo” = bar && “$bar” = foo ]
[[ $foo > 7 ]]
grep foo bar | while read line; do ((count++)); done
if [grep foo myfile]
if [bar=”$foo”]
if [ [ a = b ] && [ c = d ] ]
cat file | sed s/foo/bar/ > file
echo $foo
$foo=bar
foo = bar
echo < read more here…

g33kadmin

I am a g33k, Linux blogger, developer, student and Tech Writer for Liquidweb.com/kb. My passion for all things tech drives my hunt for all the coolz. I often need a vacation after I get back from vacation....

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.