Solved

Montage, xargs and a sorted ls

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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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…
Let's say you need to move the data of a file system from one partition to another. This generally involves dismounting the file system, backing it up to tapes, and restoring it to a new partition. You may also copy the file system from one place to…
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 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…

707 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