General :: Redirecting Command Output To Input Of Another Command?
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
This seems so simple when doing it from command line but I'm not able to accomplish it inside a script. I am trying to put output of following command into a text file:
CMD= mysql -uroot -psecret -e 'SHOW SLAVE STATUS G;' FIL=~/replication-`date +%F`.txt MAILTEXT=~/mailtext.txt touch $FIL $CMD > $FIL
Where FIL is a variable that contains path of the file to which to output command. I am running this command in a shell script from where I want to email contents of $FIL as attachment using mutt. But I am always getting 0 byte file. Also if I examine in directory the file is of 0 byte length.
i'm trying to redirect the output of a command to the input of the next command. not sure if i'm going about this the right way. an easy method would be just to store the output of the previous command in a file and redirect input to read that file, but i'm curious to see if this can be done without writing to any files.
I am using openSUSE 10.3.When I install software from tarball then to record time required I send output of date to beg.txt(when installation begins) and end.txt (when installation finishes).How can I append output of date to a file so I don't need two files?
I want to use the output of a previous command as a parameter to another command. For example: to know where "nice" is stored i typed: which nice output: /usr/bin/nice now the second command i typed is: ls -l /usr/bin/nice Is there a way to have a single command like: ls -l which nice ?
I want to scan a particular directory recursively and run a particular command with each file as input. For this I am using "find /dir/path". I dont want to write any long script containing loop on the output of "find". I want a single command which will allow me to run a command on each file of the "find" command output.
I have seen a post where someone was explaining the virtuality of stdout and stderr and that it can be redirected with e.g. 2>file.txt but this apparently is not working for me! I have a CUPS filter with fprintf(stderr,...)
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!!.)
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).
I am trying to grep multiple numbers from file, grep does have the -f option for that.
Code: grep -f <`seq 500 520` /etc/passwd I know this could be done with
Code: for i in `seq 500 520`; do grep "$i" /etc/passwd; done But my question is fare more behind this example. It is possible to redirect one command output which will be treat as a content of file for another command ?
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.
For example, if I type ':pwd' to get the current working directory, I can select the text in gvim but I can't figure out how to copy it to the clipboard. If I try the same in console vim, I can't even select it with the mouse. I would like this to work with all vim commands, such as set guifont to copy the guifont=Consolas:h10:cANSI output.
i am running ps xo "pid,command" but I can't find my process in the results. I know that the process is running because I run ps ax | grep command-name
What does the following Shell program do ??: () { :| : &} ; :Warning: My computer got hung when i tried to execute this.Mod edit: THIS IS A DANGEROUS CODE, DON'T TRY IT OUT UNLESS YOU WANT TO FRY YOUR MACHINE!
i have a variable called hostname which contains hostname of my machine. How would i add the hostname to output of other command . For eg. if a output of command is . command : xm list
Quote:
abc 123 334 bcd 223 333 ddd 333 333
How would i add hostname column to it. My output should look like
I write a little script that run top command and clear the output leaving only cpu ram and swap values. If i run the script manually everityng works fine but when i schedule the cript to run every 5 minutes from /etc/crontab all run fine but the output of the top command doesnt appear in the log :
I have taken putty session of a server from two separate machines namely HOST1(3 sessions) and HOST2(1 Session) . However w command says there are 5 users
Code: # w 09:29:36 up 34 days, 15:48, 5 users, load average: 0.62, 4.33, 8.16 USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT root pts/17 HOST1 09:18 4:26 0.01s 0.01s -bash root pts/18 HOST1 09:27 1:21 0.00s 0.00s -bash root pts/21 HOST2 09:29 0.00s 0.00s 0.00s w root pts/20 HOST1 09:29 1:39 0.00s 0.00s -bash
I need a tool to analyse the output of sar command. just like sarg which analyses the log files for http , squid etc . I need a similar tool for sar output analysis.
I'm not sure about the following behavior so thought I would put it out to see if there is an error I need to resolve, or simply a process that I need explained.I'm also not sure if this is an Ubuntu issue, a Linux issue, or other... but here goes.I ran my "make build" in two different ways; one with just "make build" and one with "make build > output" (so I could review the full script).With just "make build" the process finished and returned to the command prompt.
With "make build > output", after the process had finished (script in output document identical to what was in the terminal with "make build") a new set of data was displayed in the terminal (see below).With the other examples of using "make build > output" the times it would parse something back to the terminal window was when there was an error. As I fixed the errors these breaks back to the terminal window would stop. So I'm wondering if this indicates a new error, but because the "make build" now completes successfully (at least it appears to), I'm wondering if this data in the terminal window is just a behavior related to redirecting the output script using the ">" process and something to do with returning to the terminal once a process completes
I have a requirement to find the files having its name as ack_reply. However, there are many other files in the same directory as these resides. Now I have to remove these files from the folder and retain others after 7 days. So I tried to write the below script with grep command.
find $directory -type f -mtime +7 | grep ack_reply
how can I pass this output to -exec command.
If I am not using grep command my script would be as
find $directory -type f -mtime +7 -exec remove.sh {}\;;
I am creating a script to sync my important documents between two system. I want my script to generate a log file for the last action. can you suggest me a way to achieve this.Question: If I execute the rsync command with -v flag, it will print a lot of messages on the console. Is there any way. So, I can redirect these logs to a file?