LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 08-18-2012, 02:16 PM   #1
zsh
LQ Newbie
 
Registered: Aug 2012
Location: Russia
Distribution: Slackware
Posts: 3

Rep: Reputation: Disabled
xargs --replace or -I options


Where is a wrong?
Code:
xargs -I{} foo {} bar/$(basename {})
Instead of the substitution
Code:
$(basename /full/path)
it seems to that basename applied to {}

Thanks!
 
Old 08-18-2012, 02:27 PM   #2
David the H.
Bash Guru
 
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Arch + Xfce
Posts: 6,852

Rep: Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037
"$()" is not a system command, but a shell syntax pattern that runs the command in a subshell. xargs is not a shell, so it cannot execute it. It should be possible by having it execute "bash" or another shell, with the code as the argument to that.

BTW, it may help if you provided more details about what you are trying to do, such as what the input to this command should be, and/or what you want to get out of it.
 
1 members found this post helpful.
Old 08-18-2012, 04:17 PM   #3
zsh
LQ Newbie
 
Registered: Aug 2012
Location: Russia
Distribution: Slackware
Posts: 3

Original Poster
Rep: Reputation: Disabled
I tried to form arguments of the command convert from imagemagick package in this way

Code:
find somedir ... | xargs -I{}  convert {}  -resize 50% destdir/$(basename {})
Now to avoid error I refused from direct transfer from find to xargs via pipe

Solution looks like
Code:
list=$(find ...)
for i in $list
do
   convert $i -resize 50% destdir/$(basename $i)
done
Thanks for the help

Last edited by zsh; 08-18-2012 at 04:29 PM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
xargs: unmatched single quote; by default quotes are special to xargs unless you use Raakh5 Linux - Newbie 7 05-21-2014 07:26 PM
Using xargs SBN Linux - General 2 04-07-2008 07:44 PM
`wc`, `xargs` h/w Programming 11 09-30-2007 04:22 PM
xargs yawe_frek Linux - Software 1 04-15-2007 04:26 PM
problem in perl replace command with slash (/) in search/replace string ramesh_ps1 Red Hat 4 09-10-2003 01:04 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 01:35 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration