First off, exec is nothing like the first two. exec does a variety of things from executing a command without returning(the shell is replaced by the new command), as well as opening/closing files.
pipes transfer the output of one program into the input of another. Without the pipe or redirection, they'd be trying to read from your keyboard and trying to print to your screen, but you can feed them data from any source and send their output anywhere you like. Shell utilities are intended to be flexible that way.
'echo' prints to standard output, 'cat' reads from standard input, the pipe joins them together so 'asdf' is read by cat and printed.
But what about this:
echo does not read from standard input, it takes commandline parameters and nothing but parameters. So how do we translate from pipe into that?
This is what xargs is for.
is equivalent to command a b c d. Whenever you need to translate from a pipe or file into commandline arguments, xargs serves.
---------- Post updated at 10:28 AM ---------- Previous update was at 10:26 AM ----------
If you post some code which is confusing you, I'll try to explain it.
Hi,
I have tried both the options in small dummy scripts, but somehow i can't differentiate between the two.
find . -name H* -exec ls -l {} \;
find . -name H* | xargs ls -l
Both work the ditto way.
Any help is appreciated. (19 Replies)
Hi
I need to move multiple (say 10 files) from one location to another location. My selection would be like this...
ls -ltr *.arc | head ---> Need to move top 10 files with single command without iterating in loop. I know we can move files like this with find command but not sure if I can... (4 Replies)
What I'm trying to do is perform a copy, well a ditto actually, on the results of a find command, but some inline string substitution needs to happen.
So if I run this code find ./ -name "*.tif" I get back these results.
.//1234567.tif
.//abcdefg.tif
Now the action from exec or xargs I... (2 Replies)
Hi ,
Can somebody explain what is the difference in the below commands.. when using Xargs its giving all the hidden files and is it something xargs will do recursive searching or parsing ?
find . -type f -links 1 | xargs ls -li
find . -type f -links 1 | ls -li (1 Reply)
I have an overnight script which runs across a large directory to repair permissions and ownership. I also have this command output the list of files affected so that cron can email these as a log file. Previously I had the command in the form:
find /path/to/files -not -user myname -print -exec... (4 Replies)
I have been using unix on and off for a number of years. I am not a sys admin. I use what I need. I have googled this, but I really can't figure out what is the difference between using xarg and just using a regular pipe? Why do I need to include xarg sometimes and how do I know when I need it? (2 Replies)
Hi All,
i'm trying to create a tar of all the .txt files i find in my dir . I've used xargs to acheive this but i wanted to do this with exec and looks like it only archives the last file it finds . can some one advice what's wrong here :
find . -type f -name "*.txt" -print0 | xargs -0... (9 Replies)
Hi,
What is the difference between the following commands
find . -type f -exec grep 'abc' {} \;
and
find . -type f | xargs grep 'abc'
Appreciate your help. (2 Replies)
xargs work great when a command gives multiple line output which can be input to another. In my case it is not working coz the second command uses two words in it.
$ scr.sh
gives output like
193740
638102
375449
..
..
another command takes these number as inputs. it works great... (1 Reply)
Hello,
I am trying to move all the file listed by below command to /tmp/testing directory
find ./ -maxdepth 1 -type f -mtime +3
I tried using -exec and xargs - none of the combination is working?
Please, help (3 Replies)
Discussion started by: saurabh84g
3 Replies
LEARN ABOUT DEBIAN
dh-exec-illiterate
DH-EXEC-ILLITERATE(1) dh-exec DH-EXEC-ILLITERATE(1)NAME
dh-exec-illiterate - Write literate debhelper config files!
SYNOPSIS
#! /usr/bin/dh-exec --with=illiterate,subst,install
Greetings, my dear reader, and welcome to the awesome world of
literate programming!
Today, we're going to explore how to write a debhelper install file in
a literate manner. Trust me, it's going to be lots and lots of fun!
So, what exactly are we trying to accomplish? We're going to try
installing a file from `src/this-file' in the source tree, to a
multi-arched path in the binary file. Lets say, to
`/usr/lib/foo/${DEB_HOST_MULTIARCH}/'.
Of course, ${DEB_HOST_MULTIARCH} is a variable, and will be expanded
later in the dh-exec pipeline. It'll be something like
x86_64-linux-gnu.
Furthermore, we want to install all files from the 'usr/lib' directory
under debian/tmp. If we were writing an illiteral install file, we'd
write this rule as:
usr/lib
But the above description is much easier to understand, isn't it?
We're almost finished! One thing left to do, is to install a script
named `rename-me', to `/usr/share/foo/new-name' - we renamed it
in the process!
DESCRIPTION
The dh-exec-illiterate sub-command, unlike the others, does not serve any particular case, except to serve as a warning to all, that things
can be taken to an extreme, even with dh-exec. On the other hand, it is just like the other sub-commands in that it must not be called
directly, but through dh-exec(1), which automatically runs all available sub-commands if run bare; or explicitly with dh-exec
--with=illiterate.
It is a program that will translate its input from pretty much free-form text into something that resembles an install file. At least,
that's the only supported output format for now.
Everything that's not recognised, will be ignored, and not printed. The recognised constructs are:
`source' ... `destination'
The first string between a backtick and a single quote will be treated as the source file, the next such string will be the
destination. If the destination ends with a slash, dh-exec-illiterate will consider it a directory, otherwise it will output a
construct that dh-exec-install can recognise as a rename operation.
'source'
A string, without whitespace, between two single quotes is treated as a source, whose destination is unspecified, and is left up to
dh_install(1) to figure out.
ENVIRONMENT
DH_EXEC_SCRIPTDIR
Indicates which directory the command-specific scripts should be sought for. If not specified, scripts will be searched for in
/usr/share/dh-exec/.
FILES
$DH_EXEC_SCRIPTDIR/dh-exec-illiterate-*
The various scripts for the higher-level program.
SEE ALSO debhelper(1), dh-exec(1)AUTHOR
dh-exec-illiterate is copyright (C) 2011-2012 by Gergely Nagy <algernon@madhouse-project.org>.
2012-05-03 DH-EXEC-ILLITERATE(1)