Solved

Montage, xargs and a sorted ls

Posted on 2010-08-23
4
578 Views
Last Modified: 2013-12-26
Hi *,

I'm trying to produce a montage (with montage) of many images I have. However, if I do as follows

montage -tile 24x24 * index.png

They are inserted in the same order as ls ... which returns as the follows:

2
20
21
3
30

which I do not want, therefore I can use

ls | sort -n

to order my files correctly, however, how can I then pipe/pass this list into montage. I use xargs for other purposes such as

find . ...... | xargs rm.

It pipes each line separately which is perfect for my previous uses however I now need to pipe the whole list into montage so it can produce the image.

Any suggestions?
James
0
Comment
Question by:James_h1023
  • 2
  • 2
4 Comments
 
LVL 68

Accepted Solution

by:
woolmilkporc earned 500 total points
ID: 33499060
Try
montage -tile 24x24 $(ls | sort -n) index.png
wmp
0
 
LVL 4

Author Comment

by:James_h1023
ID: 33499124
Wonderful, that did the trick.

Incidentally, what is that called? the $() structure; so I can look up more about it.

James
0
 
LVL 68

Expert Comment

by:woolmilkporc
ID: 33499210
$( ) does essentially the same as the backticks ( ` ` ) which you might be familiar with, but is far better readable.
The concept is - start a subshell, execute the command(s) given between the parentheses or the backticks, and return the result, which will replace the whole construct.
I actually don't know whether there is a another name for that concept, besides "command substitution" and maybe "subshell"  :-)
http://tldp.org/LDP/Bash-Beginners-Guide/html/sect_03_04.html 
Thx for the points!
wmp
0
 
LVL 4

Author Comment

by:James_h1023
ID: 33499224
Brilliant some more reading to do!

Thanks very much for your help.

James
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Attention: This article will no longer be maintained. If you have any questions, please feel free to mail me. jgh@FreeBSD.org Please see http://www.freebsd.org/doc/en_US.ISO8859-1/articles/freebsd-update-server/ for the updated article. It is avail…
Over the years I've spent many an hour playing on hardened, DMZ'd servers, with only a sub-set of the usual GNU toy's to keep me company; frequently I've needed to save and send log or data extracts from these server back to my PC, or to others, and…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now