LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 03-04-2009, 10:07 AM   #1
wildtiger23
LQ Newbie
 
Registered: Mar 2003
Location: Montreal
Distribution: Slackware
Posts: 24

Rep: Reputation: 15
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
 
Old 03-04-2009, 10:35 AM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,406

Rep: Reputation: 1965Reputation: 1965Reputation: 1965Reputation: 1965Reputation: 1965Reputation: 1965Reputation: 1965Reputation: 1965Reputation: 1965Reputation: 1965Reputation: 1965
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
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Another simple scripting question Echo Kilo Linux - Newbie 10 05-14-2008 09:52 AM
simple bash scripting help shorun Linux - General 2 07-31-2007 07:26 AM
Very simple BASH scripting question clickster Linux - Newbie 6 11-23-2005 04:28 PM
Simple bash/awk/sed scripting question R00ts Programming 4 04-16-2005 02:55 AM
Bash Scripting--Simple Question mooreted Linux - General 4 05-10-2004 01:44 PM


All times are GMT -5. The time now is 01:37 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration