initializing loop to delete intermediate output files
Hi, I am running a script which produces a number of intermediate output files for each time step. is there a way to remove these intermediate files and just retain the final output at every end of the loop, like sort of an initialization process? this the inefficient way i do it.
thanks a lot.
Hi, this is a sample code I'm running. the command options are from another program and I just do sort of an automation to a series of this program built-in functions using bash.
is there a way to incorporate the rm option within the loop? thanks much.
Well,
are those programs able to read and write from and to stdin/stdout?
If yes, you could try to use variables (or pipes), instead of temporary files.
Something like this (I don't know these programs, so this is just a pseudo-code):
The here-string <<< is not standard, but most modern shells support it.
Or:
And of course, you don't need to execute ls in order to process the files:
Hi Folks -
I'm trying to build a simple for loop to accept params and then delete the folder & files on the path older than 6 days.
Here is what I have:
Purge () {
for _DIR in "$1"
do
find "${_DIR}"/* -mtime +0 -exec rm {} \;
done
}
I would be passing... (4 Replies)
Hello all,
i have a code in which when doing a for loop, i need to direct the output to two files, one just a single output, the other to always append (historical reasons).
So far i managed to do the following, which is working, but am still considering it as "dirty".
... (4 Replies)
while IFS= read -r line
do
# sV for version detection
nmap -T4 -Pn -v -sS "$line" > "text/$line"
done < <(grep '' $file)
Hi,
where line represents the IP.
I am using NMAP to do scanning.
How can I set to execute that command in the loop several concurrently at a time instead of one... (5 Replies)
I am using awk to read lines from a CSV file then put data into other files. These other files are named using the value of a certain column. Column 7 is a name such as "att" or "charter" . I want to end up with file names with the value of column 7 appended to them, like this:
... (5 Replies)
I am trying to extract the file names alone, for example "TVLI_STATS_NRT_XLSTWS03_20120215_132629.csv", from below output
which was given by the grep.
sam:/data/log: grep "C10_Subscribe.000|subscribe|newfile|" PDEWG511_TVLI_JOB_STATS.ksh.201202*
Output:
... (6 Replies)
Folks,
I am hopeful that you may be able to help me out with writing a script that can be run nightly (as cron?) to loop through all subfolders within the "/media" directory, delete all of the files in each of them, and then copy in all of the files from the "/home//sansa" directory to each of... (6 Replies)
problem with piping one output to another.Would like to avoid the intermediate file creation.The piping does nt work on places where files have been created and goes in an endless loop.
sed -e "s/^\.\///g" $LINE1| sed -e "s/_\(\)/kkk\1/g" > $file1
tr -s '_' ' ' < $file1| \
sort -n -k... (1 Reply)
hello,
i want to know how to initialize a file to an empty one in korn shell scripting? i'm using a file name and building it during a while loop using >>. The problem occurs when the file is not empty before reaching the while loop. therefore, i want to initialize it before the loop to get... (6 Replies)
Sorry for the newbie question. I'm using OSX BSD by remotely logging in and need to re-initialize the startup sequence but don't want to reboot the machine. How can I do it?
Thanks for any help. (3 Replies)