I'm writing a simple bash script to do the following:
1) Check two files (foo1 and foo2).
2) If foo1 is different from foo2 and foo1 NOT blank, send an email.
3) If foo1 is the same as foo2... or foo1 is blank... do nothing.
The blank condition is what's confusing me.
Here is an example of a file...
foo1,good
foo1,good
foo2,error
foo2,good
Note that both rows for foo1 have good in the 2nd field, but one of the foo2 rows has error...
I need something in ksh/awk/perl that will delete ALL foo2 lines if ANY of them have error in the 2nd field...so:
foo1,good
foo1,good
foo2,error
foo2,good
becomes:
foo1,good
foo1,good
Please help...I know it should be
I've got a set of data piping into a bash script.
I know this is not correct.
Bash offers the functionality to reverse search via Ctrl + R. Then one can type in a part of a command it will show a fitting entry from the history.
Assume this is my history:
vim foo1
vim foo2 # I want to go here
vim foo3 # this is where I land, how to go back?
I search for foo. Hitting Ctrl + R again shows the next fitting search entry.
Pipe binary file matches grep results to file
I am using grep to match a pattern, but the output is strange.
Code:
$ grep -r -o "pattern" *
Gives me:
Code:
Binary file foo1 matches
Binary file foo2 matches
Binary file foo3 matches
To find the lines before/after, I then have to use the following on each file:
Code:
$ strings foo1 | grep -A1 -B1 "pattern"
Ho
I have a text file (file.txt) having content something like:
foo1 3464
foo2 3696
foo3 4562
It contains the process and respective PID.
Using shell script, I want to append a string (running/not running) to that lines in this file, according to the PID.
For example, in the above file, for line containing PID 3696, I want to append a string "running" at the end, so that the file becomes:
fo
CentOS 5.x
I'm trying to build a shell script that searches data provided via stdin.
I have a large directory of music files that is often changing as files and directories come and go.