Process files

#!/bin/bash
cd "`dirname "$0"`"

IFS=$'\n'
for fil in `ls`; do
    filename=$(basename "$fil")
    extension=${filename##*.}
    filename=${filename%.*}
    echo $fil
done

Process a file line-by-line

#!/bin/bash
BASE=$(readlink -f `dirname "$0"`)

INFILE="filename"

i=0
lines=$(wc -l "$INFILE" | cut -d ' ' -f 1)
while read line; do
    i=$(($i+1))
    echo -en "$i/$lines | $line"
done < "$INFILE"

Spawn a terminal

#!/bin/bash

if ! tty -s; then
    gnome-terminal -x "$0"
    exit
fi

echo 'Some terminal'

CGI

#!/bin/bash
echo -e "Content-type: text/html\n"

cat <<eof
<html>
    <head>
        <title>Some Page</title>
    </head>
    <body>
        Some Text
    </body>
</html>
eof

No comments yet.

Leave a Comment

I respect your privacy
I don't run any trackers on this site.

Your questionable browsing-history should remain between you and the NSA ;-)
Contact