The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

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
Redirect Output Multi-Process djodjo High Level Programming 3 03-17-2008 05:55 PM
problem parsing process-output victorin Shell Programming and Scripting 3 07-25-2006 05:31 AM
Can ps just output the process name? blckleprd Shell Programming and Scripting 4 06-07-2006 11:46 PM
Opening output file while still in process monkfan UNIX for Dummies Questions & Answers 4 03-02-2006 04:35 AM
Retreive process output nhatch UNIX for Advanced & Expert Users 2 10-16-2003 10:55 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-19-2008
eich eich is offline
Registered User
  
 

Join Date: Feb 2008
Posts: 2
Using ls output for other process

Hello,

Just to set the tone: I am a complete UNIX noob (i guess you see that excuse popping up frequently here but anyhow)
Now here's my bloody simple problem which needs to be quite urgently resolved: I have a number of files in a directory, for which the ones, relevant for executing a subsequent action, can be easily gathered using an ls -1 | cut -c1-5 command. What I want to do know is plug in each filename resulting out of this ls command into another command. Hence, I need to temporarily store each name into a variable, execute the other command by using that variable and then move on to the next one untill the list is finished.

PS: if someone knows a fool proof unix guide on the web which enables even an amoebe to learn unix, feel free to post the link.

Thanks.
  #2 (permalink)  
Old 02-19-2008
ilan ilan is offline
Registered User
  
 

Join Date: Jul 2007
Posts: 101
for i in `ls`; do echo $i;done

-ilan
  #3 (permalink)  
Old 02-20-2008
eich eich is offline
Registered User
  
 

Join Date: Feb 2008
Posts: 2
Quote:
Originally Posted by ilan View Post
for i in `ls`; do echo $i;done

-ilan
This comes close but not yet perfect. Now "i" is filled with just the regular filename, but I need to have that string made shorter with the cut command.
  #4 (permalink)  
Old 02-20-2008
manikantants manikantants is offline
Registered User
  
 

Join Date: Feb 2008
Posts: 131
for i in `ls | cut -c1-5 `; do echo $i; done
Closed Thread

Bookmarks

Tags
backtick, command substitution

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 08:37 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