Programming :: Shell Script - Which Should Diff Between PS Outputs
Feb 16, 2010
I would like to make a one-liner, which diff's "ps aux" output before and after killing a process. So basically it should be a combination of fallowing commands:
1) diff -u
2) ps aux | awk '{print $2}'
3) kill `ps aux | grep [c]ron | awk '{print $2}'`
4) ps aux | awk '{print $2}'
How to achieve this? Something like this:
Code:
diff $( kill `ps aux | grep [c]ron | awk '{print $2}'` && ps aux | awk '{print $2}' ) $( ps aux | awk '{print $2}' )
I don't have pgrep or pkill available.
View 3 Replies
ADVERTISEMENT
Jan 7, 2010
I have a directory that has about 5,000+ folders in it and I'd like to run a script that outputs any directory that contains a subdirectory.
View 4 Replies
View Related
Oct 27, 2010
I have been having some fun with the shell but have become a little lost. I want to be able to email (myself and others) outputs from various commands etc. Sometimes people wish to know the contents of my music library etc and it's nice to be able to ssh in and email an ls (or similar) output.
Here is what I have been doing:
Code:
ls -R /home/simon/mount/sata0/audio > /tmp/musiclist
mail -s $(date +%Y%m%d) email@domain.com < /tmp/musiclist
The date part works perfectly and I receive an email with a subject suiting my preferential YYYYMMDD format.
But what I'd like to figure out is how to get this into a single line of code, my first attempt was:
Code:
mail -s $(date +%Y%m%d) email@domain.com < $(ls -R /home/simon/mount/sata0/audio)
This generates an error:
-bash: $(ls -R /home/simon/mount/sata0/audio): ambiguous redirect
But if I simply run the code "ls -R /home/simon/mount/sata0/audio" - the output is exactly what I want.
Is what I'm trying to do even possible? I do realise that I could use something like this
Code:
ls -R /directory > /tmp/file && mail -s $(date +%Y%m%d) email@domain.com < /tmp/file
But this is still running two commands and I'd like to figure out how to be 'cleverer'.
View 2 Replies
View Related
Apr 20, 2011
I have 500 folders of templates in one folder. Now each folder has file called template_thumbnail.png . now i want something so that all those files get copied to one folder with name same as the home folder name
I have cygwin installed and i can copy that folder in there so basically it will linux shell script
View 1 Replies
View Related
Jun 6, 2011
I hav a shell script that outputs few variables. i want to output them in a table format. any unix commands?
The output i need is:
View 4 Replies
View Related
Jun 2, 2010
I like the output of
Code:
git diff --color-words old..new
but I do not know how to set --color-words permanently in the ~/.gitconfig file.
Edit: I guess I should've said that I do not want an alias for diff --color-words
View 5 Replies
View Related
Jun 19, 2010
Does diff not like arrays? How do achieve the following?
Code:
stuart@stuart:~/music transfer$ diff file1.txt file2.txt
1c1
< bonkers_in_phoenix.mp3
[code]....
View 14 Replies
View Related
Aug 2, 2010
I've been able to get the right output that I need from sed, but how can I execute the string that sed actually outputs?
View 3 Replies
View Related
Jan 26, 2009
I want to catch some outputs in two different log files in bash, file simple.log and all.log So far, the script is started like this:
Code:
xterm -e "(./myscript.sh | tee -a simple.log) >& all.log"
What I want is:
- In simple.log, I want all the stdout but WITHOUT errors.
- In all.log I want BOTH stdout and stderr.
So all is ok, and the output becomes:
all.log
Code:
starting copying files
mv: cannot move ... : permission denied
copying completed
simple log
Code:
starting copying files
copying completed
But, in the new xterm, I'm loosing stdout. There is no output.How can I have the files logged as they are but also have the stdout in the xterm.
View 6 Replies
View Related
Dec 26, 2010
I'm new to scripting and I have a trouble with if statement syntax. The code is: Code: #there is a diff command here, and it does what i want but#i wanna see 1 if the exit value of diff is 0, and otherwise i wanna see 0.#the problem is here: (syntax error near unexpected token "then")
if["$?"==0];
then
echo 1
[code].....
View 1 Replies
View Related
Nov 5, 2010
I would like to compare two md5sum outputs to see if the files match. in my script I have
Code:
ORG_FILE="/path/to/org/file.zip"
NEW_FILE="path/to/new/file.zip"
MD5_ORIG=$(md5sum -b "$ORG_FILE")
[code]....
How do I get just the MD5 hash and not the */.... stuff so I can compare them. i tried Code: JUST_HASH=${$MD5_ORIG:0:32} but All I get is
dir_mon_notify.sh: line 79: ${$MD5_ORIG:0:32}: bad substitution
View 1 Replies
View Related
Sep 10, 2010
Consider this PHP Script or just skip to the Output:
Code
Code:
-bash-2.05b# cat myDate.php
#!/usr/bin/php -q
<?php
[code]....
View 10 Replies
View Related
Jul 16, 2009
I'm writing a script using ksh that diffs two dirs that contain about 30 files, and writing the results on a logfile. When files differ, it writes the difference with no problem, but I also need the script to write a message if no differences are found.
View 3 Replies
View Related
Sep 4, 2010
I have a requirement like this:Cut the characters from each line of a file with following positions: 21-24, 25-34 ,111-120.Thse fields now need to be placed in a tab delimited output file.Currently this is how I am achieving it:
#!/bin/sh
cat newsmaple.txt | cut -c 21-24 > out1.txt
cat newsmaple.txt | cut -c 25-34 >out2.txt
[code]....
View 1 Replies
View Related
Jun 5, 2011
I am trying to create a shell script similar to ls, but which only lists directories. I have the first half working (no argument version), but trying to make it accept an argument, I am failing. My logic is sound I think, but I'm missing something on the syntax.
Code:
if [ $# -eq 0 ] ; then
d=`pwd`
for i in * ; do
if test -d $d/$i ; then
echo "$i:"
code....
View 10 Replies
View Related
Jun 25, 2010
Is there some type of functional way to read things in the Python shell interpreter similar to less or more in the bash (and other) command line shells?
Example:
Code:
>>> import subprocess
>>> help(subprocess)
...
[pages of stuff to read]
...
I'm hoping so as I hate scrolling and love how less works with simple keystrokes for page-up/page-down/searching etc.
View 4 Replies
View Related
Dec 15, 2009
I've created a simple script based menu. This menu will be accessed by only a certain users via ssh.When user logs in, the menu will automatically run. (configured at user's .bash_profile).How do I force the session to close when user hits Ctrl-C or Ctrl-Break ?In a nutshell, I don't want user to have access to shell.
View 11 Replies
View Related
Jan 21, 2011
I recently started shell programming and my task now is to do a menu display.Currently i am stuck whereby user will input both title and author and it will delete it.
Do i have to use sed command?
View 4 Replies
View Related
May 17, 2010
Is it possible to assist in the programming Shell Scripts
Job:
To send a message to the email,All orders written in Terminal or ssh
example : ls , pwd , cat , and other
View 1 Replies
View Related
Apr 15, 2009
I have centos 5.29 on one hard drive in a box and now someone wants to hook up his own XP Hard drive every now and then when I am not using centos.
Rather than have to disconnect everytime, is there a way I can have the 2 drives in the box and have the option at bootup which one to use?
View 1 Replies
View Related
Feb 4, 2011
I have a situation where I am in a non-interactive shell. I have tried from within my non-interative shell to spawn an interactive shell but my output still does not goto me. Isn't there a way I can somehow go into /proc or somwhere and make the output my /dev/tty1? Or some way else to remedy this?The situation arises because I drop from my restricted shell environment (a sort of CLI interface), into the actual Linux shell. I cannot change the code of the CLI environment I am just faced with being in the linux shell environment and its non-interactive. Its very annoying to have to put > /dev/tty1 after every command I type.
Not to mention it seems damn near impossible to get pagers like more and less to work properly when your in a non-interactive shell.
View 2 Replies
View Related
Jun 18, 2010
when i compile a software ABySS, it reported that:
/usr/local/include/google/sparsehash/libc_allocator_with_realloc.h:66: warning: unused parameter 'n'
make[2]: *** [libalign_a-Aligner.o] Error 1
make[2]: Leaving directory `/var/data/abyss-1.2.0/Align'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/var/data/abyss-1.2.0'
make: *** [all] Error 2
someone said it because of a bug of google-sparsehash. and gave a patch "deallocate.diff ". my problem is how to use deallocate.diff to fix the bug.
View 1 Replies
View Related
Sep 17, 2010
When I build my software with rpmbuild command, the rpms are not gettinggenerated in the directory specified in rpmmacros file(%_rpmdir)This is what I am doing..
rpmbuild -bb -vv --buildroot <build root path> --target=x86_64 --rcfile /tmp/rpmrc /tmp/mySpecfile.spec
# cat /tmp/rpmrc
[code]....
View 3 Replies
View Related
Jun 27, 2011
I downloaded a package with an extension .diff.gz. I extracted it and got a .diff file. how to install a .diff file?
View 1 Replies
View Related
Apr 19, 2010
1/ I haven't catch the difference between dwdiff, diff or dircomp If one wants to only output files (JPEG, doc, etc.), which have been created, absent or modified The command:
diff -r -q
works well, any advantage for another command? Subtilities between commands for issues like:
* identical content, but renamed files
* identical names & date & weight, but different content (virus)
2/ Is there a way to tell diff to store in a specific directory all missmatched files?
Something as
diff - r -q oldBackup actualData /media/sda1/discrepant
Where diff would store in media/sda1/discrepant all files which are new or modified after comparison between oldBackup and actualData
View 1 Replies
View Related
Jul 6, 2011
I would like to compare the (screen) output of one bash script with the (screen) output of another bash script to ensure the output is exactly the same.The reason for this is that I am receiving a consolidated data feed from an IP address and have moved some of the data feed to a 'new' source IP address. I will turn off the feed from the original once satisfied that the new is receiving the same data. The format of the output from the scripts are exactly the same.
Tried so far
./IDCGRE.sh | grep FX.CK | diff < ./IDCGRE2.sh
./IDCGRE.sh | grep FX.CK | ./IDCGRE2.sh | diff
[code]...
View 3 Replies
View Related
Nov 30, 2010
I have two H/D and i need to install XP and RHEL5.3 in different H/D connected to single machine.so that when i boot from first H/D linux will boot or if i choose second XP will boot.
View 7 Replies
View Related
Feb 8, 2010
Where can i find such subj? I don't see that standart diff supports such feature. It will be used for backup big directory like /home. Because directory is too big so repositories like svn are unacceptable. Good case seems to be diff+tar.gz to save differences for last n-th monthes for example. /home could contain doth hard and symbolic links that are not resolvable on backup machine but could have sense at all (= be resolvable on other machines where /home is used too via nfs mounting).
View 4 Replies
View Related
Jan 27, 2011
Since i upgraded to F14 I have been having an annoying problem with compiz: I have twinview and an nvidia 8800GTS. Windows like transmission and pidgin that i put on my second monitor and then hide, have their position reset to the center left side of the screen on the absolute border of the first monitor. this is probably a problem with how compiz is detecting the outputs.
EDIT: Any windows that have their position saved to the second screen will be reset to hug the center left side of the screen.
SOLVED: I manually set the outputs in compiz and the selected use largest output first in Place Windows plugin.
View 2 Replies
View Related
Mar 21, 2010
I'm trying to use this thread to set my laptop's resolution to 640x480. To do this, I need to use the addmode command which expects me to list an OUTPUT. What OUTPUT do I list? The "xrandr -q" command doesn't list any outputs.Here is the result of me typing "xrandr -q":
Code:
Screen 0: minimum 800 x 600, current 1024 x 768, maximum 1024 x 768
default connected 1024x768+0+0 0mm x 0mm
[code]...
View 5 Replies
View Related