LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 12-16-2008, 11:48 PM   #1
sp1dy7
LQ Newbie
 
Registered: Dec 2008
Posts: 1

Rep: Reputation: 0
Cool Can sum1 explain how this script works in linux.......


for i in `ls -1r`;do sh $i; done;
 
Old 12-17-2008, 02:16 AM   #2
joshuas3521
LQ Newbie
 
Registered: Dec 2008
Location: Birmingham, Alabama
Distribution: Debian/Custom
Posts: 7

Rep: Reputation: 0
for i in `ls -1r`; do
sh $i;
done;

It runs all shell scripts in the current directory. It translates out to this:

for every file 'i' in the current directory
call "sh i" (where i is the name of the file)

so, if you had a directory that had the following files:
bar.sh
e.sh
foo.sh
x.sh

it would execute
Code:
sh x.sh
sh foo.sh
sh e.sh
sh bar.sh
The -1r argument simply tells ls to list the files in reverse order, one per line.

Last edited by joshuas3521; 12-17-2008 at 02:23 AM.
 
  


Reply



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
Can someone explain how this script works? Sanborn Programming 18 06-15-2007 08:53 AM
Please explain the way the program works. Gins Programming 7 03-22-2006 06:17 PM
Please explain how dd works and what it does ohovus Linux - Newbie 4 12-13-2005 08:48 AM
Please explain to me how VDR works with DVB? jimdaworm Linux - Software 2 09-04-2004 04:06 PM
can sum1 plzzz help me!! diminishedpower Linux - Software 1 08-12-2003 06:44 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 11:29 AM.

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration