Hi,
I have a file color.txt which has data as shown below
Based on a variable I execute a tail command as shown below
LEFT_OVR can be any number less than count of number of lines in a file
so if LEFT_OVR=2, then output would be
Based on output of tail command I need to build a dynamic If condition, which will look something like this
I'm planning to do something like this
Next I would check for occurrence of ] [ and replace with ] || [
Any ideas if there is something easier to achieve similar result?
Last edited by rbatte1; 05-11-2015 at 12:55 PM..
Reason: CODE tags for output
With LEFT_OVR=4, try
Unfortunately, you'll need to use the unloved eval to take advantage of above, or output it into a temp file that you source, then.
Would something like this, base on a case statement work?
I get the following simple sample output:-
You could easily set the variables t1, t2, t3 etc. based on your tail output and set all the others to be dummy or the like to effectively switch off those tests.
Another way might be to build up an array from the tail output and then have a loop around the if statement to check each one set in turn. It depends quite what you need to achieve I suppose.
EDIT-Note:
My files were named identical but with another file extension (sh/txt).
Though, to be accurate for snooker values, the colors would need to be in order.
EDIT2:
Outputs like:
EDIT3 - Explanation:
Sets variable C to 1, and declares varable BALL as ALPHA indexed Array. (not quiet sure on the ALPHA label, ity my 'donkey-bridge')
Read from file $0 (the execute[d|r] script), but remove first occourence of sh with txt within its filename,
expand each line to the only passed variable color.
Since the (in this example) used scriptname and content-file-name are identical but their file extension not, this works quite fine.
${color,,} makes the content of variable color to small letters, since usualy people forget to press shift when passing options or arguments to commands.
So it set the array index $color to value $C, then increment that value. (could be shortened to ((C++)) in this case, or ((counter++)) whatsoever you use for an index/counter)
Finaly we print out the the desired information. 'downcode' the passed argument to small letters, just to be sure, so it matches the array index, which is now set to letters (the color names).
Hi All,
I have already code to create folder for one country let say US , now we want to create folder/directory for JP country also using shell script , application server.
$COUNTRY='US'
if ]
then
if mkdir -m 777 -p /opt/TEST/$COUNTRY/$INVOICE >/dev/null 2>&1 | tee -a ... (5 Replies)
I need to write the list of files to a new file in one column , the second column would contain the first line of that file (header record extracted through head -1 ) and the third column would contain the last record of that file (trailer record tail -1 ) .
Example :- folder where the files... (8 Replies)
Hi All,
I am really struggling to solve this problem, this might be small but I am not able to, can somebody help me?
I have few directories and these directories receives text files in large amount with in fraction of seconds. So I just want to send all the files in current directory to... (2 Replies)
I am currently running 2 scripts to gather data for a 3rd script and would like to combine the 2 scripts into one. Having issues with the final output format.
Note cannot post URL so replaced the http stuff with (name) in the examples
All scripts contain #!/bin/ksh OS = Red Hat Enterprise... (0 Replies)
hi,
I have some problems in my simple script about the redirect echo stdout command inside a condition. Why is the echo command inside the elif still execute in the else command
Here are my simple script
After check on the two diff output the echo stdout redirect is present in two diff... (3 Replies)
Problem :
I want to create a separate file for country list if condition is true. Please help.
*****************************************************
Input file:
SV-INCR-139302-365540488-201104090934.sqllog
SV-INCR-1082-552793184-201104040805.sqllog
SV-INCR-1077-855045741-201104040805.sqllog... (4 Replies)
I have a file that reads File (X.txt)
Contents of record 1:
rdrDESTINATION_ADDRESS (String) "91 971502573813"
rdrDESTINATION_IMSI (String) "000000000000000"
rdrORIGINATING_ADDRESS (String) "d0 movies"
rdrORIGINATING_IMSI (String) "000000000000000"
rdrTRAFFIC_EVENT_TIME... (0 Replies)
hi
i hav files ha1j ha2m ha3n ha4q ha5s ...like tat im having some 20 files ..and i want to create a folder as the same amount of files which im having wen the condition if loop is satisfied ..
thank you (5 Replies)
Hi falks,
I need to write a function in k-shell which cd to root directory and ask the user which sub directory you want to tar.
The user will select directories untill quit.
How to do it?
Thanks in advance,
Nir (4 Replies)