Solved

Montage, xargs and a sorted ls

Posted on 2010-08-23
4
587 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Java performance on Solaris - Managing CPUs There are various resource controls in operating system which directly/indirectly influence the performance of application. one of the most important resource controls is "CPU".   In a multithreaded…
Background Still having to process all these year-end "csv" files received from all these sources (including Government entities), sometimes we have the need to examine the contents due to data error, etc... As a "Unix" shop, our only readily …
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…

726 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