General :: Xargs - How Some Command Receive Input From Both Sides
Mar 9, 2010
I would like to ask the following:
1) ls -l |grep test -> this will grep every "ls -l" output line
2) ls -1 |xargs grep test -> this will grep every single file with test
3) ls -1 |xargs echo -> this will echo directory list
4) ls -1 |echo -> this does nothing!!!
My question is: how some command can receive input from "both sides" (grep can grep whole output or every single file - xargs, the same is for i.e. wc command). 4) echo does nothing (it's a single echo command).
View 1 Replies
ADVERTISEMENT
Mar 29, 2010
I just recently learned about the wonderful little lpr command- and using man -t (bash command) to beautifully print man pages for reference- but is there a way to print both sides of the paper using a printer so equipped?
View 2 Replies
View Related
Mar 24, 2011
I often want to extract some info using awk from a variable/filename while running other things using xargs and sh. Below is an example:
Code: ls -1 *.txt | xargs -i sh -c 'NEW=`echo $0 | awk -F'_' '{print $1}'`; echo $NEW' {}
In the above case I would like to grab just the first field from a filename (delimited by '_') from within an sh command. This is a simplified example, where normally I would be doing some further data processing with the sh command(s).
The error message that I get is:
Code: }`; echo $NEW: -c: line 0: unexpected EOF while looking for matching ``'
}`; echo $NEW: -c: line 1: syntax error: unexpected end of file.
I haven't been able to figure out how to escape the awk command properly.
View 1 Replies
View Related
Jun 17, 2011
I get this behavior on Slackware 13.37, which includes BASH 4.1.010. Yes, BASH is my shell. I have a file called a.flac and I'm in the directory that contains it.
The output of the ls command is expected:
Code:
ls *.flac
gives:
Code:
a.flac
Removing the extension with basename works as expected:
Code:
basename a.flac .flac
gives:
Code:
a
Putting the above command in a variable substitution works as expected:
Code:
echo `basename a.flac .flac`
gives:
Code:
a
Using xargs with ls and a variable substitution works as expected:
Code:
ls *.flac | xargs -i echo `echo {}`
gives:
Code:
a.flac
However, when I try to add the basename command to the above command, it stops working.
Code:
ls *.flac | xargs -i echo `basename {} .flac`
gives:
Code:
a.flac
Whereas the result I expect is:
Code:
a
Why is it not working, and how do I make it work?
View 3 Replies
View Related
Jul 2, 2011
I want to run gsettings list-schemas (which return a list of about 100 names separated by spaces)and somehow direct each name one at a time as the input to this command:gsettings list-recursivelyI've tried it with awk, and standard | piping and also as a string variable strvar=$(gsettings list-schemas) and using the $strvar as the input butam missing something in between I'm sure like for - while or proper syntax of awk etc
View 3 Replies
View Related
Dec 20, 2010
I am attempting to record my microphone input using ffmpeg / alsa but always receive the following error:
[code]...
Using arecord works perfectly with hw:0,0. I had also tried to use /dev/snd/hwC0D0 as input but I receive an error from alsa saying that it doesn't exist (despite it existing and having adequate permissions). I know absolutely nothing about hardware but am comfortable around the command line
View 2 Replies
View Related
Sep 19, 2010
When Linux ask for my password in command line,my keyboard becomes unresponsive just for that moment or let me put it this way,until i need to write my password my keyboard is unresponsive,but for all other things is fine.or for example,i can input my password when i have a graphic interface but i can't with command line or i can't login to my computer from command lineexcuse me if my question is doll,i moved from windows to ubuntu just lastweek,( & i am flying high in sky with ubuntu & digging a very deep hole for windows too!!.)
View 2 Replies
View Related
Jun 29, 2011
I have a directory like this:
mkdir test
cd test
touch file{0,1}.txt otherfile{0,1}.txt stuff{0,1}.txt
I want to run some command such as ls on certain types of files in the directory and have the * (glob) expand to all possibilities for the filename.
echo 'file otherfile' | tr ' ' '
' | xargs -I % ls %*.txt
This command does not expand the glob and tries to look for the literal 'file*.txt'
How do I write a similar command that expands the globs? (I want to use xargs so the command can be run in parallel)
View 1 Replies
View Related
Jun 23, 2011
I increase my knowledge in vim in two ways. Little hints about doing this or that and scattered studies using the vim help files. Please do not believe I always rely on the first one.
View 12 Replies
View Related
Jun 10, 2009
I'm trying to copy a list of files except the files which has ".log" in the filename to another folder.I can run it correctly when I am located in the Source folder, but not when I am in any other location.cd /home/me/Sourcels /home/me/Source -1|grep -v "^.*log$" |xargs -n 1 -iHERE cp -r HERE /home/me/DestinationHow can I indicate both Source and Destination Folder?
View 2 Replies
View Related
Mar 18, 2010
Please explain why
Code:
echo some_directory | xargs cd
is not working.
Code:
echo some_directory | xargs ls
is working as expected.
View 14 Replies
View Related
Jun 17, 2011
I want to insert a picture into a group of pictures (I memorized their names in a text file) resulting a new group of picture (which I also memorized their name in another text file), but I have a problem doing that. I want to write something like that:
$> cat file1 | cat file2 | xargs composite -blend 30 text.jpg line_file1 line_file2
where
file1 is:
frame1.jpg
frame2.jpg
frame3.jpg
....
and file2 is:
new_frame1.jpg
new_frame2.jpg
new_frame3.jpg
...
View 4 Replies
View Related
Jun 22, 2009
I'm trying to find all zip files timestamped from the past 7 days, then unzip them into a different director.I tried the following, but it only unzipped one of three files that meet the 7 day criteria. What am I missing?Code:find /home/user/public_html/zip_files/ -iname "*.zip" -mtime -7 -print0 | xargs -n10 unzip -LL -o -d /home/user/public_html/another_directory/
View 1 Replies
View Related
May 15, 2011
I need your inputs on performing some operations:-
a. Traverse from top Level directory, find all the directories
b. Rename all these directories to <original name>.dir
c. Once the renaming is done - search from top level and retain only those directories which has .txt content in them.
d. Delete rest all.....
Can i use xargs here to perform operation a and b , or will sed will be useful.
View 14 Replies
View Related
May 20, 2011
Background: I want to send and receive emails from the command line. I'm an OS X immigrant and I don't know my way around a shell. I learned what sudo and man pages are last week. I'm hoping to learn more by doing more in the Terminal, and I check my emails a lot, so that would be a nice place to start. I've had a root around, but there doesn't seem to be much on the relevant fora or wikis to help me. The core of the problem: When I enter
Code:
$ mail
the shell returns
Code:
No mail for USER
I know that there's mail waiting for me. When I log into Gmail in my web browser, I can see it. So, I assume that the problem is that heirloom-mailx (the mail app I've installed) isn't connecting to my Gmail account for some reason. I originally also noticed that I couldn't send emails by typing
Code:
$ mail name@address.tld but I found this post, and after following the steps it outlines, I have successfully composed and sent mail from the command line. I assume that I have just missed some fundamental final step in linking my Gmail account with mailx.
Do you know what I need to do to fix this? I'm really enjoying getting to grips with Linux, and I don't want to be stopped now by what seems to be such a piffling problem.
View 9 Replies
View Related
Apr 3, 2010
Suppose I want to account number of files beginning with abc , I can use "ls 'abc* | grep abc | wc -l", this will return me a number.
I want to store this number in a variable, say var1, so I tried
1. "ls 'abc* | grep abc | wc -l |read var1", but this didn't work as var1 has no value somehow.
2. var1='ls 'abc* | grep abc | wc -l', this just assign the entire string "ls 'abc* | grep abc | wc -l" to var1, which is not I wanted.
I don't want to store the value to a temporary file and then read the value from that file. I think there should be a direct way to get the value, but don't know how. I know in tcsh, one can just use set var1='ls 'abc* | grep abc | wc -l', but it also doesn't work in bash. Can anyone give any clue about this?
View 5 Replies
View Related
Sep 7, 2010
While making a shell ,there is the following problem Im facing:
I am expecting the user to enter commands in the following format :
I am to separate these and the output of ls -l should be given as input to grep and the output of both to more.
But I am allowed (by our instructor) to use dup/dup2 or any other command(but not pipe or tees).
How to connect the file descriptors after successful execution of each command?
View 5 Replies
View Related
Apr 7, 2010
I used linux for a long time now, mostly ubuntu-based distros but these days I decided to try openSUSE. Must say, It is a really nice distro, with lots of new features. There is one that I never seen before but I admit it is very useful: the auto resize window feature. I use the 11.3 (KDE) (milestone 4) version. Just wanted to ask if this is a package for ths or is hard-coded into the system? And is it KDE-specific?
View 2 Replies
View Related
Apr 19, 2010
I have managed to get Compiz Desktop Cube working with 4 viewports. Everything is great but I have noticed the that cube will show the running applications in the bottom panel, from the previously active viewport, on all sides of the cube.
Anyone know how to set it so that the bottom panel on each side of the cube displays only the applications that are running in the currently visible viewport? I hope that's clear because I'm not 100% sure of the terminology.er to determine the viewport you are looking for.
View 3 Replies
View Related
Jan 29, 2010
Maybe there is something good,multiplatform, arm, mips, linux, windows.. Python, I guess can. I didnt find anything in database
A two side app would be great:
- left , the topic
- right, the content
something like this for instance : [URL] but in non-X11 like (so in console)
View 1 Replies
View Related
Jul 15, 2010
I wanna trace user's command input history. but I dont plan to use "history", "lastcomm" becauze there is not detail of the user command history. if there is some software use to log user command to one file or database, it's suit for me.
View 1 Replies
View Related
Jul 12, 2010
I need to create backup of internal drive and write it on DVD. I want to do this in single command...like below: ntfsclone -f --save-image --overwrite - /dev/sda1 | growisofs -Z /dev/sr1=/dev/stdin
in above command, i tried to to create backup of first partition of internal drive and need to write this backup on DVD. But above command has some probolem due to which it could not write backup on DVD....and how to read from standard input in 'growisofs' command?
View 2 Replies
View Related
Jan 31, 2011
It has been happening to me since I started to use this laptop from the company for a linux test bed. Several times a day, when I do something from the command line, for example running an application connecting to another host on the internet, etc,it comes to a freeze and does not come out of it. I can not do anything else than a forced reboot from the power button, because the keyboard and the mouse do not respond. This work laptop is a lenovo W500, running on ubuntu jaunty, release 9.04. I have not encountered this problem before with my personal laptop though. My person laptop is a lenovo X61s, running on ubuntu karmic, release 9.10Should I reinstall the work laptop with some other version of ubuntu? Could it be some hardware problem ? What tools should I use to diagnose
View 2 Replies
View Related
Jan 25, 2011
There is a syntactical feature I would like to see in Vim, and so I thought to write myself a syntax file for my needs, but I am having trouble finding the exact type of syntax highlighting I want to incorporate'emulate. Currently in Vim, from the terminal instead of say gvim, when I place my cursor over a parenthesis or brace, the corresponding brace or parenthesis will highlight, or block its character. In my case, instead of a single character they will be full words specified within the syntax file.
I want to do something similar. For example if my document has three words:
Group
Element1
Element2
I want the syntax file to tell Vim that when I have my cursor over the word Element1 or Element2 that Group will become highlighted. In the same, to have the cursor over Group will cause both Element1 and Element2 to highlight. I have looked here but understanding still eludes me: [URL]. I would also be happy with creating some sort of command input, where I type in the group name and the elements highlight. Like a very specific search function that searches for only and all instances that are contained within the group named.
View 4 Replies
View Related
Jul 6, 2011
Since 13.37 I notice that vi needs the 'home' key to switch from input to command mode. I think this is only when I connect via Putty to the machine. When I am on local console it is still ESCape like it used to be. Does anyone know how to set it so that vi will switch from input to command mode using the ESCAPE key when using Putty?
Another vi question :
When you edit htm files, vi goes automagically into some sort of html display mode. Ofcourse I never want that since all I do is edit the html in vi. So I need to go to command mode and type :normal everytime I want to edit html files. Where can you configure that vi (or vim) default to normal mode always?
<I see that vi links to elvis : >
# ls -al /usr/bin/vi lrwxrwxrwx 1 root root 5 Oct 3 2009 /usr/bin/vi -> elvis*
View 6 Replies
View Related
Mar 21, 2009
I have written a CGI script which prints 2 tags at either end of the screen (actually they are the "Previous page" and "Next page" links for either end of the screen). The left one is under a <DIV ALIGN="LEFT"></DIV> and the right one <DIV ALIGN="RIGHT"></DIV>. Unfortunately they don't line up on screen - the left "Previous page" text is one line higher than the "Next page" link - I tried putting in a <NOBR> tag between them but it didn't work - can someone tell me what to do?
View 7 Replies
View Related
Jul 15, 2011
I'm testing some multi-plat java code and I'm getting a bit frustrated with the Linux tests. I need to run the command:
Code:
$ java -jar /home/developer/TCO/TabletComicOptimizer.jar <file> <args[]>
against all the files that match a specific criteria. I've tried various find syntax and I can't seem to get it right.
Normally I would just create a bash script and populate the results of find into an array and then just enumerate the collection but in this specific case I want to demonstrate this operation at the bash terminal.
I've tried things like:
Code:
~/TCO $ find . -type f -iname "*.cb[rz]" | xargs java -jar TabletComicOptimizer.jar {} 1200x1800 ;
Thinking that the {} is the substitution for each file returned by find but it's not working. How do I execute my java program against each result in the find operation?
View 6 Replies
View Related
Sep 28, 2010
I am running 10.04 Lucid on a Toshiba Satellite A105. The onboard video is an Intel Graphics Media Accelerator 950. The issue is that when I connect it to my Panasonic widescreen TV (laptop is widescreen as well) the display is shrunk and has a lot of unused space on the sides/top/bottom. So like, if I wanna watch something from Hulu, I plug in the S-Video, and I can watch on the TV, but it's not using all the screen available... I have not found a way to resize the output so it fills the screen.
View 6 Replies
View Related
Jan 23, 2010
I used the command shown below to remove a list of software using yum. It worked, but is there a way of doing this without using the -y option? I would like to review the results before the transaction takes place. I would like to use the same method for installing additional software after a clean install.
cat filename | xargs yum -y remove
View 8 Replies
View Related
May 25, 2011
I will eventually script this but wanted to know where I screwed up when trying to get this oneliner to work. In a nutshell, I want to created a backup directory, find any files that have changed in the last 48hrs and them copy them to the newly made backup directory.
PHP Code:
date=$(date +%m%d%Y)mkdir -p /home/test_dir/backup$date;find . -mtime 1|xargs -0 cp -r -t /home/test_dir/backup$date
When I do this I get:
PHP Code:
a bunch of junk !#$#$$#! File name too long
I also tried:
PHP Code:
date=$(date +%m%d%Y)mkdir -p /home/test_dir/backup$date;find
. -mtime 1|xargs -0 cp -r {} /home/test_dir/backup$date
View 7 Replies
View Related