Home Man
Search
Today's Posts
Register

BSD, Linux, and UNIX shell scripting — Post awk, bash, csh, ksh, perl, php, python, sed, sh, shell scripts, and other shell scripting languages questions here.

Pipe data to shell script

Tags
shell scripts

👤 Login to reply

 
Thread Tools Search this Thread
# 1  
Old 03-14-2007
Pipe data to shell script

Sorry about the noobish question but...

How do I capture data thats piped to my script?

For instance,
Code:
ls -al | myscript.sh

How do I access the output from ls -al in myscript.sh?
# 2  
Old 03-14-2007
Quote:
Originally Posted by tomjones07
Sorry about the noobish question but...

How do I capture data thats piped to my script?

For instance,
Code:
ls -al | myscript.sh

How do I access the output from ls -al in myscript.sh?
A basic simple way

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

# 3  
Old 03-14-2007
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...
Code:
cat > file1

# 4  
Old 03-14-2007
cheers guys
👤 Login to reply

« Previous Thread | Next Thread »
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
How to pipe command output to shell script? gvkumar25 Shell Programming and Scripting 11 02-18-2015 12:02 AM
Shell script to read lines in a text file and filter user data Shell Programming and Scripting VikrantD UNIX for Dummies Questions & Answers 3 03-25-2014 03:28 AM
Read pipe data shubh05 Shell Programming and Scripting 7 12-11-2012 01:19 PM
Convert column data to row data using shell script sktkpl UNIX for Advanced & Expert Users 4 06-06-2012 05:55 AM
Data pipe lost when using ssh in shell script siavash Shell Programming and Scripting 2 02-01-2012 06:28 AM
Using Named pipe in shell script sudvishw Shell Programming and Scripting 2 09-12-2011 05:21 AM
Need help with shell script for chekking a column in txt file - pipe delimited ravi0435 UNIX for Dummies Questions & Answers 12 01-02-2009 03:31 PM
Reading from blocking fifo pipe in shell script victorin Shell Programming and Scripting 4 05-08-2007 11:39 AM
Pipe Data From Grep Into A File katinicsdad Shell Programming and Scripting 4 09-08-2006 11:20 AM
Need help capturing pipe to a file in shell script heinz Shell Programming and Scripting 6 11-03-2005 07:27 AM


All times are GMT -4. The time now is 01:05 PM.

Unix & Linux Forums Content Copyright©1993-2018. All Rights Reserved.
UNIX.COM Login
Username:
Password:  
Show Password