The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
ksh: cmd output to input of another script IMTheNachoMan Shell Programming and Scripting 2 04-27-2008 10:58 AM
Using Output from one command as input to another BkontheShell718 Shell Programming and Scripting 2 12-26-2007 04:23 PM
v3fshelper: There is an input or output error padawan75 AIX 2 11-21-2007 08:56 AM
kickstart output/input maskot Red Hat 3 05-31-2007 11:24 AM
log script input and output using tee ? moseschrist Shell Programming and Scripting 0 11-12-2006 03:32 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 02-14-2008
rodrimuino rodrimuino is offline
Registered User
  
 

Join Date: Sep 2007
Posts: 4
Cool Using output to input another command

Hi guys. Is it possible (I'm sure it is) to use the output of a simple 'ls' command as input of another command 'tail'.
It is not really the output of the 'ls'. I have to useeach line of the output.

This is the first command...
ls *myFile*021308*

Which it outputs many filenames. For each of those filenames I want to tail them

tail 1.myFlie_021308
tail 2.myFlie_021308

Thanks
Rodrigo
  #2 (permalink)  
Old 02-14-2008
joeyg's Avatar
joeyg joeyg is offline Forum Staff  
modérateur
  
 

Join Date: Dec 2007
Location: Home of 17-time world champion Boston Celtics
Posts: 1,311
Cool Use a for loop

#! /bin/bash

for zf in *myfile*.*
do
ls -l $zf
tail $zf
done

Notes:
(1) I do an ls command; not needed - just shows what file is being looked at in the loop
(2) tail is its own command line since guess you want to do more than simply execute this one command

This could all be done in one line as:
tail *myfile*.*
but, I figure this is part of something more complicated.
So, two choices.
  #3 (permalink)  
Old 02-14-2008
andryk's Avatar
andryk andryk is offline Forum Advisor  
Registered User
  
 

Join Date: Sep 2003
Posts: 448
Quote:
Originally Posted by rodrimuino View Post
Hi guys. Is it possible (I'm sure it is) to use the output of a simple 'ls' command as input of another command 'tail'.
It is not really the output of the 'ls'. I have to useeach line of the output.

This is the first command...
ls *myFile*021308*

Which it outputs many filenames. For each of those filenames I want to tail them

tail 1.myFlie_021308
tail 2.myFlie_021308

Thanks
Rodrigo
Here's another one if you kind of like the output/input style
Code:
ls | xargs -n1 tail

  #4 (permalink)  
Old 02-14-2008
rodrimuino rodrimuino is offline
Registered User
  
 

Join Date: Sep 2007
Posts: 4
Thank you both. It was easier than I thought!

Rodrigo
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 03:45 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0