[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Montage, xargs and a sorted ls

Posted on 2010-08-23
4
Medium Priority
?
599 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 68

Accepted Solution

by:
woolmilkporc earned 2000 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Using libpcap/Jpcap to capture and send packets on Solaris version (10/11) Library used: 1.      Libpcap (http://www.tcpdump.org) Version 1.2 2.      Jpcap(http://netresearch.ics.uci.edu/kfujii/Jpcap/doc/index.html) Version 0.6 Prerequisite: 1.      GCC …
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…
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…
In a previous video, we went over how to export a DynamoDB table into Amazon S3.  In this video, we show how to load the export from S3 into a DynamoDB table.
Suggested Courses

649 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