Pipe data to shell script

Sorry about the noobish question but...

How do I capture data thats piped to my script?

For instance,

ls -al | myscript.sh

How do I access the output from ls -al in myscript.sh?

A basic simple way

#!/usr/bin/ksh
cat - | while read LINE
do
  echo aa${LINE}bb
done

The first command in your script will accept the input from the pipe. So if you just want to capture it to a file, then try...

cat > file1

cheers guys :slight_smile: