LinuxQuestions.org
Visit Jeremy's Blog.
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 01-05-2013, 12:35 PM   #1
antriksh
Member
 
Registered: Aug 2010
Location: In my world
Distribution: RHEL 6.4
Posts: 57

Rep: Reputation: 0
Question Explain me the meaning of this line in shell script


Code:
for file in /{,usr/}bin/*calc


Above line is used to find all executable files ending in "calc" in /bin and /usr/bin directories. in the article it is said that ',' is used to concatenate strings. Can anyone explain this in little detail how ',' is concatenating strings here?
 
Old 01-05-2013, 12:44 PM   #2
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374Reputation: 2374
The {,usr/} part consists of 2 strings. One being usr/ (part after the comma), the other is "empty" (the part before the comma).

This, for example would list /bin and /sbin:
Code:
ls -l /{bin,sbin}/
And this lists /bin, /sbin, /usr/bin and /usr/sbin:
Code:
ls -l /{,usr}/{bin,sbin}/
 
1 members found this post helpful.
  


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
bash shell script read file line by line. Darren[UoW] Programming 51 07-04-2013 08:16 PM
How to pass command line arguments from one shell script to another shell script VijayaRaghavanLakshman Linux - Newbie 5 01-20-2012 09:12 PM
How to identify a line and replace another string on that line using Shell script? Sid2007 Programming 10 10-01-2007 08:49 PM
'./file' meaning in python & shell script Chowroc Programming 7 12-30-2005 02:32 AM


All times are GMT -5. The time now is 09:47 PM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration