LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   bash scripting simple question (https://www.linuxquestions.org/questions/programming-9/bash-scripting-simple-question-709139/)

wildtiger23 03-04-2009 10:07 AM

bash scripting simple question
 
Presently i'm using this script like this :

./myscipt.sh file1.txt.

But for personnal reason I would like to use it this way :

cat file1.txt | myscript.sh

and i can't find out how...

thanks for your help

#!/bin/sh
:
# Start sending data
(
copies=1
files="$1"
i=1
while [ $i -le $copies ] ; do
for file in $files ; do
# insert init strings here
printf "\033E" # Reset printer
printf "\033&k2S" # Compress printing
printf "\033&k2G" # crlf
printf "\033(s3B" # bold
cat ${file}
printf "\014" # Send form feed
done
i=`expr $i + 1`
done
) | lp -s -dW1PP

acid_kewpie 03-04-2009 10:35 AM

you'd use a while read loop...

Code:

#!/bin/sh

a=1
b=2
c=whatever

while read A_LINE_OF_TEXT
do
  something -to $A_LINE_OF_TEXT
done



All times are GMT -5. The time now is 05:07 AM.