The bash below loops through a specific directory dir and finds and writes the oldest folder to a variable called $filename.
Result output stored in /home/cmccabe/medex.logs/folder.log
The variable (in bold) is also written to a log file stored at/home/cmccabe/medex.logs/folder.log.
So the R_2017_01_13_12_11_56_user_S5-00580-24-Medexome would be extracted and saved as $filename for the below processes to use.
So basically store the portion in bold from the log in the filename variable so the other lines can use it to execute.
The problem is there could be multiple lines in the log, but only one returned from the bash. The line that is returned from the bash
needs to be matched to a line in log and stored as filename.
So in the log there may be 3 lines:
But on 1 returned by the bash
So, R_2017_01_13_12_11_56_user_S5-00580-25-Medexome would be stored in the $filename variable.
I am really not sure how to do this and hope I posted enough information. Thank you .
Last edited by cmccabe; 01-17-2017 at 07:53 PM..
Reason: fixed format
There is no creation date recorded for files (be they plain files, directories, pipes, sockets, devices, ..... etc) so it is unclear what results you will get. You are reading the modification time for the directory, i.e. the last time that a file was created/removed/renamed or had it's ownership/permissions changed and these are all going to be difficult to police.
What is the overall point of the process? Maybe we can consider a better way.
The modification date is being used in the bash to determine the oldest file.
3 .tar.bz2 folders are downloaded and extracted by aria2cand the modification time of each folder is read by the bash.
That value starts with R_ always is stored as $filename but does not carry over the subsequent lines, so they don't execute.
Since $filename is written to the output log in the post, maybe it could be extracted? The problem is there could be multiple lines in that log, but only one $filename. That the variable needed for the subsequent lines. Thank you very much .
I can not figure out how to capture the $filename variable store by the bash.
#!/bin/bash
# oldest folder stored as variable for analysis, version log created, and quality indicators matched to run
dir=/home/cmccabe/Desktop/NGS/test
find "$dir" -maxdepth 1 -mindepth 1 -type d -printf... (5 Replies)
Heyas
So while i'm trying to increase security/usability of my TUI commands, i'm currently at tui-conf-get.
There was also a bug, i wanted to fix, but sadly that bugfix is more insecure - but twice as fast as my current buggy method.
I've added a getopts toggle, '-s' to toggle beSecure,... (8 Replies)
Using a bash for loop to pass variables into a nawk loop to capture a string in an sftp log. Tried several different syntax methods to have the variable treated as a regex so the loop will capture the string.
for i in `cat /tmp/dar3.out.2`
do
nawk -vst=$i '$5 ~ /$st/ && /closed/ && /user/... (3 Replies)
Hello, I am quite new in shell scripting and I would like to write a little scritp to run a program on some parameters files.
all my parameters files are in the same directory, so pick them up with
ls *.para >>dirafter that I have a dir file like that:
param1.para
param2.para
etc...
I... (2 Replies)
Hi!
I need to do the following:
(1) I wan't to extract a line of a textfile (defined by a numer) and store it into a variable...
(2) ...but I want to cut out a part of the line which is between two tokens and store just this to the variable
Example:
BlaBlaBla Bla2Bla2Bla2 *pPointerOne;... (4 Replies)
Hello, Would someone guide me on how to write a shell script the would search for a phone no using at the end text file using sed or awk and store it in a varaible or print it.
The text file is in this form
text or numbers in first line
text or numbers in second line
.
.
.
Firsname... (6 Replies)
Example output:
/tmp/generatelines.sh
line1
line2
line3
line4
I want each output line assigned to its own variable, ie:
"line1" --> $a
"line2" --> $b
"line3" --> $c
"line4" --> $d
Is this possible without writing to a temporary file?
Thanks (4 Replies)
Let a script needs a variable to execute. For example if i run ./test.sh then it needs a variable as there is a <STDIN> in the script. I want to execute it as in command line.
Let test.sh requires a variable name $number I want to execute it by
>test number <enter>
how is it possible? (1 Reply)
Hi all,
I'm quite new to unix and hope that someone can help me on this.
I'm using csh.
Below is what i intend to do.
1. I stored some data in a file.
2. I intend to read the file line by line and store each line of data into a variable, so that i can used it later.
Anyone have any... (4 Replies)