Solved

Montage, xargs and a sorted ls

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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Suggested Solutions

When you do backups in the Solaris Operating System, the file system must be inactive. Otherwise, the output may be inconsistent. A file system is inactive when it's unmounted or it's write-locked by the operating system. Although the fssnap utility…
I promised to write further about my project, and here I am.  First, I needed to setup the Primary Server.  You can read how in this article: Setup FreeBSD Server with full HDD encryption (http://www.experts-exchange.com/OS/Unix/BSD/FreeBSD/A_3660-S…
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…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.

758 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

22 Experts available now in Live!

Get 1:1 Help Now