I've got a set of data piping into a bash script.
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.
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
I know this is not correct.
Hi,
I have a script which will use an input.txt file as an input file.
I am providing data to this input file in the script and once the script is executed, I want to clear all the contents of this file as during the second time use of this script, I'll be appending the data in this input file.
So basically I want to know a way using which I can just clear all the contents of the file input.tx
Let's say i want to run a bash script, is there a command in the terminal to specifiy the values that my script would ask for instead of using read?
for example at the time that i type bash script1.sh can i somehow type values to pass to the script or does it first have to be executed.
Like bash script1.sh 3 4
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 have the following bash script lines in a file named test.sh.
Code:
#!/bin/bash
#
# Write Date to cron.log
#
echo "Begin SSI Load $(date +%d%b%y_%T)"
#
# Get the latest rates file for processing.
#
d=$(ls -tr /rms/data/ssi | grep -v "processed" | tail -n 1)
filename=$d
export filename
echo "The file name is $filename."
When I execute ./test.sh
I've never really thought about how the shell actually executes piped commands. I've always been told that the "stdout of one program gets piped into the stdin of another," as a way of thinking about pipes. So naturally, I thought that in the case of say, A | B, A would run first, then B gets the stdout of A, and uses the stdout of A as its input.