Sponsored Content
Full Discussion: Help with test statement
Top Forums Shell Programming and Scripting Help with test statement Post 302482622 by drbiloukos on Wednesday 22nd of December 2010 05:50:50 AM
Old 12-22-2010
Complete script:

Code:
#!/usr/bin/sh
old_IFS=$IFS
IFS=$' '
echo MINUTES\;HOURS\;DAY_OF_MONTH\;MONTH\;DAY_OF_WEEK\;SCRIPT\;CFG\;P1\;P2\;LOG
cat cron.txt | sed '/^$/d' | sed '/^#/d'| sed 's/>//g' | sed 's/ (. ~\/.profile ; timex / /g'| sed 's/)/ /g' | sed 's/ 2&1//g' | sed 's/*/+/g' | tr -s ' ' | sed
 's/ / /g' | while read mins hours day_of_mon month day_of_week script cfg p1 p2 log
do
if [ "$log" = "" ]
then
log="${p2}"
p2=""
fi
if [ "$log" = "" ]
then
log="${p1}"
p1=""
fi
if [ "$cfg" = log ]
then
log="${cfg}"
cfg=""
fi
 
echo ${mins}\;${hours}\;${day_of_mon}\;${month}\;${day_of_week}\;${script}\;${cfg}\;${p1}\;${p2}\;${log}
done
IFS=$old_IFS
exit

Sample from cron.txt
Code:
30 04  *  *  * (. ~/.profile ; timex /Data/bin/load_data.sh /Data/bin/1.cfg ) 2>&1
32 04  *  *  * (. ~/.profile ; timex /Data/bin/load_data.sh /Data/bin/2.cfg ) 2>&1
00 05  *  *  * (. ~/.profile ; timex /Data/bin/load_data.sh /Data/bin/3.cfg ) >> /Data/logs/load_data.log 2>&1

 

7 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Using grep in a test/if statement

Okay, well this is more or less my first attempt at writing a shell script. Anyways, here's my code: cd ${PATH} if then rm ${FILE} ./anotherScript else exit 1 fi exit 1 Anyways, it's a pretty simple script that is supposed to search for the... (4 Replies)
Discussion started by: cbo0485
4 Replies

2. UNIX for Dummies Questions & Answers

if test statement

Can you use an if statement after an else? example if then echo "word" else if then echo "word" (1 Reply)
Discussion started by: skooly5
1 Replies

3. Shell Programming and Scripting

Test on string containing spacewhile test 1 -eq 1 do read a $a if test $a = quitC then break fi d

This is the code: while test 1 -eq 1 do read a $a if test $a = stop then break fi done I read a command on every loop an execute it. I check if the string equals the word stop to end the loop,but it say that I gave too many arguments to test. For example echo hello. Now the... (1 Reply)
Discussion started by: Max89
1 Replies

4. Shell Programming and Scripting

Perl - automating if statement test

Hello all, I'm trying to automate an if statement in my Perl script. The script opens an input file for reading, checks each line in the file for a particular substring, and if it finds the substring, writes it to an output file. There are approximately 200 different input files. Each has... (3 Replies)
Discussion started by: Galt
3 Replies

5. Shell Programming and Scripting

How to check weather a string is like test* or test* ot *test* in if condition

How to check weather a string is like test* or test* ot *test* in if condition (5 Replies)
Discussion started by: johnjerome
5 Replies

6. Shell Programming and Scripting

string test in IF statement

How do I test multiple words in a string test like below: if ] then print "You entered $TBS name.\n" else print "You entered an incorrect response.\n" fi This test does not work. I have tried different syntax versions. How does this work? And is there a better way to do it? ... (10 Replies)
Discussion started by: djehresmann
10 Replies

7. Shell Programming and Scripting

If statement test against number range [0-9]

Is it possible to test against a varible within a ranges in a if statement. ex. if ];then echo "not in range" else echo "number within range" fi (8 Replies)
Discussion started by: leemalloy
8 Replies
set_color(1)							       fish							      set_color(1)

NAME
set_color - set_color - set the terminal color set_color - set the terminal color Synopsis set_color [-v --version] [-h --help] [-b --background COLOR] [COLOR] Description Change the foreground and/or background color of the terminal. COLOR is one of black, red, green, brown, yellow, blue, magenta, purple, cyan, white and normal. o -b, --background Set the background color o -c, --print-colors Prints a list of all valid color names o -h, --help Display help message and exit o -o, --bold Set bold or extra bright mode o -u, --underline Set underlined mode o -v, --version Display version and exit Calling set_color normal will set the terminal color to whatever is the default color of the terminal. Some terminals use the --bold escape sequence to switch to a brighter color set. On such terminals, set_color white will result in a grey font color, while set_color --bold white will result in a white font color. Not all terminal emulators support all these features. This is not a bug in set_color but a missing feature in the terminal emulator. set_color uses the terminfo database to look up how to change terminal colors on whatever terminal is in use. Some systems have old and incomplete terminfo databases, and may lack color information for terminals that support it. Download and install the latest version of ncurses and recompile fish against it in order to fix this issue. Version 1.23.1 Sun Jan 8 2012 set_color(1)
All times are GMT -4. The time now is 11:09 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy