LinuxQuestions.org
Register a domain and help support LQ
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-17-2008, 12:48 AM   #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, 03: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 03:23 AM.
 
  


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


All times are GMT -5. The time now is 01:50 PM.

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration