suppose an apache log file gets deleted but its held open by apache then this is what i am doing.
pid=$(lsof | grep text.txt | awk '/deleted/ {print $2}')
fd=$(lsof | grep text.txt | awk '/deleted/ {print $4}' | grep -oE "[[:digit:]]{1,}")
cp /proc/$pid/fd/$fd directorytobecopied/testfile.txt
this is what i am doing to recover the file and put it back where it was.
is there any simpler way of
Hi to all,
I'm here again, cause I need your help to solve another issue for me.
I have some files that have this name format: date_filename.csv
In my shell I must rename each file removing the date so that the file name is filename.csv
To do this I use this command:
Code:
fnames=`ls ${fname}| awk '{ FS = "_*" } ; { print $2 }'`
where fname contain, for example, 20120906_TESTFI
I think I know what this is doing, but the 'eval' is confusing
Code:
fname=$(echo ${lineItem} | awk 'BEGIN {FS=";"}{print $1}')
fname=${fname%%+([[:space:]])}
fname=${fname##+([[:space:]])}
eval "fname=${fname}"
The first line extracts the contents of the line preceeding the ";"
2nd & 3rd lines trim the value (I think ..
This question is a sequel of sorts to my earlier question. The users on this site kindly helped me determine how to write a bash for loop that iterates over string values. For example, suppose that a loop control variable fname iterates over the strings "a.txt" "b.txt" "c.txt". I would like to echo "yes!" when fname has the value "a.txt" or "c.txt", and echo "no!" otherwise.
I am new in Fortran. Can anybody tell me why I cannot read a string from the txt into NAME
The first row of the txt file contains "Line". When I print NAME.
In bash, I know that it is possible to write a for loop in which some loop control variable i iterates over specified integers. For example, I can write a bash shell script that prints the integers between 1 and 10:
#!/bin/bash
for i in {1..10}
do
echo $i
done
Is it possible to instead iterate over a loop control variable that is a string, if I provide a list of strings?
I have an hourly hour-long crontab job running with some mtr (traceroute) output every 10 minutes (that is going to go for over an hour prior to it being emailed back to me), and I want to see the current progress thus far.
On Linux, I have used lsof -n | fgrep cron (lsof is similar to BSD's fstat), and it seems like I might have found the file, but it is annotated as having been deleted (a stand
Hi,
I have a problem when doing calculations in awk.
I want to add up a few numbers and output the result.
testfile:
Code:
48844322.87
7500.00
10577415.87
3601951.41
586877.64
1947813.89
Code:
$ awk '{x=x+$1};END{print x}' testfile
6.55659e+07
The problem is the number format. It should show '65565881.68', not '6.55659e+07'.
Does anyone know how to fix this?
Thanks
i have a variable that has more than one value. i am declaring another variable, which will have the old variable data one by one. i want to use the second variable to hold the track of all the variable it has parsed from the first one.