Friday, October 9, 2009

Linux - Bash Shell Scripting - Displaying Text from a Shell Script

An executing script can display text on the console window using the echo command. For example,

#!/bin/bash
# usage: rmwild dir pattern
dirname=$1
pattern=$2
echo "Removing all $2 files from $1..."
cd $dirname
rm $pattern 2> /dev/null
echo "Done."
$ ls tmp
file1.c file1.o file2.c file2.o
$ rmwild tmp *.o
Removing all *.o files from tmp...
Done.
$ ls tmp
file1.c file2.c

Previous - Aliases | Next - A Simple Backup Script

No comments:

Post a Comment