To reduce the bash script length!!!


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting To reduce the bash script length!!!
# 1  
Old 03-19-2011
To reduce the bash script length!!!

Hi friends,

at last i finish my script to find the status of the URL , in this code i used all the status codes, because of this it take too much of length. with the help of wiki only i find all the status codes.

Status codes in HTTP

Quote:
and my question is do we need all the status codes necessary in this script..

and is there any other way to reduce the code using any conditonal statements..
Code:
#!/bin/bash
timevar=`date +%d-%m-%Y_%H.%M.%S` #-- > Storing Date and Time in a Variable
get_contents=`cat /urls.txt`  #-- > Getting content of website from file. Note the file should not contain any http:// as its already been taken care of
######### Next Section Does all the processing #########
for i in $get_contents
do
statuscode=`curl -connect-timeout 30 -w “totaltime:%{time_total}\n” -s -I -L http://$i | awk '{for(i = 1; i<=NF; i++) if($i=="“totaltime:0.000n”“totaltime:0.000n”HTTP/1.1") print $(i+1);}'`
case $statuscode in
200) 
    echo "$timevar $i $statuscode okay" >> /log.txt;;

201) 
    echo "$timevar $i $statuscode created" >> /log.txt;;


202) 
    echo "$timevar $i $statuscode Accepted" >> /log.txt;;


203) 
    echo "$timevar $i $statuscode Non-Authoritative Information" >> /log.txt;;


204) 
    echo "$timevar $i $statuscode No Content" >> /log.txt;;


205) 
    echo "$timevar $i $statuscode Reset Content" >> /log.txt;;

206) 
    echo "$timevar $i $statuscode Partial Content" >> /log.txt;;

207) 
    echo "$timevar $i $statuscode Multi-Status" >> /log.txt;;


226) 
    echo "$timevar $i $statuscode IM Used" >> /log.txt;;


300) 
    echo "$timevar $i $statuscode Multiple choices" >> /log.txt;;


301) 
    echo "$timevar $i $statuscode Moved Permanently" >> /log.txt;;

302) 
    echo "$timevar $i $statuscode found" >> /log.txt;;

303) 
    echo "$timevar $i $statuscode See Other" >> /log.txt;;


304) 
    echo "$timevar $i $statuscode Not Modified" >> /log.txt;;


305) 
    echo "$timevar $i $statuscode Use Proxy" >> /log.txt;;


306) 
    echo "$timevar $i $statuscode UnUsed" >> /log.txt;;



307) 
    echo "$timevar $i $statuscode Temporary Redirect" >> /log.txt;;


400) 
    echo "$timevar $i $statuscode Bad Request" >> /log.txt
    echo "Status $statuscode found" | mail -s "Check of $i failed" 07anis@gmail.com  ;;     

401) 
    echo "$timevar $i $statuscode Unauthorized" >> /log.txt
    echo "Status $statuscode found" | mail -s "Check of $i failed" 07anis@gmail.com |  >> /root/log.txt;;

402) 
    echo "$timevar $i $statuscode Payment Required" >> /log.txt
    echo "Status $statuscode found" | mail -s "Check of $i failed" 07anis@gmail.com;;

403)
    echo "$timevar $i $statuscode Forbidden" >> /log.txt
    echo "Status $statuscode found" | mail -s "Check of $i failed" 07anis@gmail.com;;

404)
    echo "$timevar $i $statuscode Page Not Found" >> /log.txt
    echo "Status $statuscode found" | mail -s "Check of $i failed" 07anis@gmail.com;;



405)
    echo "$timevar $i $statuscode Method Not Allowed" >> /log.txt
    echo "Status $statuscode found" | mail -s "Check of $i failed" 07anis@gmail.com;;


406)
    echo "$timevar $i $statuscode Not Acceptable" >> /log.txt
    echo "Status $statuscode found" | mail -s "Check of $i failed" 07anis@gmail.com;;


407)
    echo "$timevar $i $statuscode Proxy Authentication Required" >> /log.txt
    echo "Status $statuscode found" | mail -s "Check of $i failed" 07anis@gmail.com;;


408)
    echo "$timevar $i $statuscode Request Timeout" >> /log.txt
    echo "Status $statuscode found" | mail -s "Check of $i failed" 07anis@gmail.com;;


409)
    echo "$timevar $i $statuscode Conflict" >> /log.txt
    echo "Status $statuscode found" | mail -s "Check of $i failed" 07anis@gmail.com;;


410)
    echo "$timevar $i $statuscode Gone" >> /log.txt
    echo "Status $statuscode found" | mail -s "Check of $i failed" 07anis@gmail.com;;

411)
    echo "$timevar $i $statuscode Length Required" >> /log.txt
    echo "Status $statuscode found" | mail -s "Check of $i failed" 07anis@gmail.com;;


412)
    echo "$timevar $i $statuscode Precondition Failed" >> /log.txt
    echo "Status $statuscode found" | mail -s "Check of $i failed" 07anis@gmail.com;;

413)
    echo "$timevar $i $statuscode Request Entity Too Large" >> /log.txt
    echo "Status $statuscode found" | mail -s "Check of $i failed" 07anis@gmail.com;;

414)
    echo "$timevar $i $statuscode Request-URI Too Long" >> /log.txt
    echo "Status $statuscode found" | mail -s "Check of $i failed" 07anis@gmail.com;;

415)
    echo "$timevar $i $statuscode Unsupported Media Type" >> /log.txt
    echo "Status $statuscode found" | mail -s "Check of $i failed" 07anis@gmail.com;;

416)
    echo "$timevar $i $statuscode Requested Range Not Satisfiable" >> /log.txt
    echo "Status $statuscode found" | mail -s "Check of $i failed" 07anis@gmail.com;;


417)
    echo "$timevar $i $statuscode Expectation Failed" >> /log.txt
    echo "Status $statuscode found" | mail -s "Check of $i failed" 07anis@gmail.com;;


422)
    echo "$timevar $i $statuscode Unprocessable Entity" >> /log.txt
    echo "Status $statuscode found" | mail -s "Check of $i failed" 07anis@gmail.com;;


423)
    echo "$timevar $i $statuscode Locked" >> /log.txt
    echo "Status $statuscode found" | mail -s "Check of $i failed" 07anis@gmail.com;;

424)
    echo "$timevar $i $statuscode Failed Dependency" >> /log.txt
    echo "Status $statuscode found" | mail -s "Check of $i failed" 07anis@gmail.com;;


425)
    echo "$timevar $i $statuscode Unordered Collection" >> /log.txt
    echo "Status $statuscode found" | mail -s "Check of $i failed" 07anis@gmail.com;;


426)
    echo "$timevar $i $statuscode Upgrade Required" >> /log.txt
    echo "Status $statuscode found" | mail -s "Check of $i failed" 07anis@gmail.com;;

444)
    echo "$timevar $i $statuscode No Response" >> /log.txt
    echo "Status $statuscode found" | mail -s "Check of $i failed" 07anis@gmail.com;;

449)
    echo "$timevar $i $statuscode Retry With" >> /log.txt
    echo "Status $statuscode found" | mail -s "Check of $i failed" 07anis@gmail.com;;


450)
    echo "$timevar $i $statuscode Blocked by Windows Parental Controls" >> /log.txt
    echo "Status $statuscode found" | mail -s "Check of $i failed" 07anis@gmail.com;;


499)
    echo "$timevar $i $statuscode Client Closed Request " >> /log.txt
    echo "Status $statuscode found" | mail -s "Check of $i failed" 07anis@gmail.com;;


500)
    echo "$timevar $i $statuscode Internal Server Error" >> /log.txt
    echo "Status $statuscode found" | mail -s "Check of $i failed" 07anis@gmail.com;;


501)
    echo "$timevar $i $statuscode Not Implemented" >> /log.txt
    echo "Status $statuscode found" | mail -s "Check of $i failed" 07anis@gmail.com;;


502)
    echo "$timevar $i $statuscode Bad Gateway" >> /log.txt
    echo "Status $statuscode found" | mail -s "Check of $i failed" 07anis@gmail.com;;

503)
    echo "$timevar $i $statuscode Service Unavailable" >> /log.txt
    echo "Status $statuscode found" | mail -s "Check of $i failed" 07anis@gmail.com;;

504)
    echo "$timevar $i $statuscode Gateway Timeout" >> /log.txt
    echo "Status $statuscode found" | mail -s "Check of $i failed" 07anis@gmail.com;;

505)
    echo "$timevar $i $statuscode HTTP Version Not Supported" >> /log.txt
    echo "Status $statuscode found" | mail -s "Check of $i failed" 07anis@gmail.com;;

506)
    echo "$timevar $i $statuscode Variant Also Negotiates" >> /log.txt
    echo "Status $statuscode found" | mail -s "Check of $i failed" 07anis@gmail.com;;

507)
    echo "$timevar $i $statuscode Insufficient Storage" >> /log.txt
    echo "Status $statuscode found" | mail -s "Check of $i failed" 07anis@gmail.com;;

509)
    echo "$timevar $i $statuscode Bandwidth Limit Exceeded" >> /log.txt
    echo "Status $statuscode found" | mail -s "Check of $i failed" 07anis@gmail.com;;

510)
    echo "$timevar $i $statuscode Not Extended" >> /log.txt
    echo "Status $statuscode found" | mail -s "Check of $i failed" 07anis@gmail.com;;


esac
done


Please guide me...legends!!!

With Regards
Anish kumar.V
# 2  
Old 03-19-2011
just a thought, didn't test.

you could save a text file for those fixed code-info content, say
Code:
200|ok
201|created
...

after you get $statuscode, go to that file and find out the info you want, could be done by awk, for example. then, if the $statuscode >=400, executing your mail -s command.
# 3  
Old 03-19-2011
Code:
#!/bin/bash
timevar=$(date +%d-%m-%Y_%H.%M.%S) #—– > Storing Date and Time in a Variable
get_contents=`cat /urls.txt`  #—- > Getting content of website from file. Note the file should not contain any http:// as its already been taken care of
######### Next Section Does all the processing #########
function _echo () {
	echo $1 $2 $3 $4  >> /log.txt
}
func _mail () {
	echo "Status $1 found" | mail -s "Check of $2 failed" 07anis@gmail.com
}
for i in $get_contents
do
statuscode=`curl –connect-timeout 30 -w “totaltime:%{time_total}\n” -s -I -L http://$i | awk '{for(i = 1; i<=NF; i++) if($i=="“totaltime:0.000n”“totaltime:0.000n”HTTP/1.1") print $(i+1);}'`

case $statuscode in
	200) _echo $timevar $i $statuscode "okay";;
	201) _echo $timevar $i $statuscode "created";;
	202) _echo $timevar $i $statuscode "Accepted";;
	203) _echo $timevar $i $statuscode "Non-Authoritative Information";;
	204) _echo $timevar $i $statuscode "No Content";;
	205) _echo $timevar $i $statuscode "Reset Content";;
	206) _echo $timevar $i $statuscode "Partial Content";;
	207) _echo $timevar $i $statuscode "Multi-Status";;
	226) _echo $timevar $i $statuscode "IM Used";;
	300) _echo $timevar $i $statuscode "Multiple choices";;
	301) _echo $timevar $i $statuscode "Moved Permanently";;
	302) _echo $timevar $i $statuscode "found";;
	303) _echo $timevar $i $statuscode "See Other";;
	304) _echo $timevar $i $statuscode "Not Modified";;
	305) _echo $timevar $i $statuscode "Use Proxy";;
	306) _echo $timevar $i $statuscode "UnUsed";;
	307) _echo $timevar $i $statuscode "Temporary Redirect";;
	400) _echo $timevar $i $statuscode "Bad Request"; _mail $statuscode $i;;     
	401) _echo $timevar $i $statuscode "Unauthorized"; _mail $statuscode $i;;
	402) _echo $timevar $i $statuscode "Payment Required"; _mail $statuscode $i;;
	403) _echo $timevar $i $statuscode "Forbidden"; _mail $statuscode $i;;
	404) _echo $timevar $i $statuscode "Page Not Found"; _mail $statuscode $i;;
	405) _echo $timevar $i $statuscode "Method Not Allowed"; _mail $statuscode $i;;
	406) _echo $timevar $i $statuscode "Not Acceptable"; _mail $statuscode $i;;
	407) _echo $timevar $i $statuscode "Proxy Authentication Required"; _mail $statuscode $i;;
	408) _echo $timevar $i $statuscode "Request Timeout"; _mail $statuscode $i;;
	409) _echo $timevar $i $statuscode "Conflict"; _mail $statuscode $i;;
	410) _echo $timevar $i $statuscode "Gone"; _mail $statuscode $i;;
	411) _echo $timevar $i $statuscode "Length Required"; _mail $statuscode $i;;
	412) _echo $timevar $i $statuscode "Precondition Failed"; _mail $statuscode $i;;
	413) _echo $timevar $i $statuscode "Request Entity Too Large"; _mail $statuscode $i;;
	414) _echo $timevar $i $statuscode "Request-URI Too Long"; _mail $statuscode $i;;
	415) _echo $timevar $i $statuscode "Unsupported Media Type"; _mail $statuscode $i;;
	416) _echo $timevar $i $statuscode "Requested Range Not Satisfiable"; _mail $statuscode $i;;
	417) _echo $timevar $i $statuscode "Expectation Failed"; _mail $statuscode $i;;
	422) _echo $timevar $i $statuscode "Unprocessable Entity"; _mail $statuscode $i;;
	423) _echo $timevar $i $statuscode "Locked"; _mail $statuscode $i;;
	424) _echo $timevar $i $statuscode "Failed Dependency"; _mail $statuscode $i;;
	425) _echo $timevar $i $statuscode "Unordered Collection"; _mail $statuscode $i;;
	426) _echo $timevar $i $statuscode "Upgrade Required"; _mail $statuscode $i;;
	444) _echo $timevar $i $statuscode "No Response"; _mail $statuscode $i;;
	449) _echo $timevar $i $statuscode "Retry With"; _mail $statuscode $i;;
	450) _echo $timevar $i $statuscode "Blocked by Windows Parental Controls"; _mail $statuscode $i;;
	499) _echo $timevar $i $statuscode "Client Closed Request"; _mail $statuscode $i;;
	500) _echo $timevar $i $statuscode "Internal Server Error"; _mail $statuscode $i;;
	501) _echo $timevar $i $statuscode "Not Implemented"; _mail $statuscode $i;;
	502) _echo $timevar $i $statuscode "Bad Gateway"; _mail $statuscode $i;;
	503) _echo $timevar $i $statuscode "Service Unavailable"; _mail $statuscode $i;;
	504) _echo $timevar $i $statuscode "Gateway Timeout"; _mail $statuscode $i;;
	505) _echo $timevar $i $statuscode "HTTP Version Not Supported"; _mail $statuscode $i;;
	506) _echo $timevar $i $statuscode "Variant Also Negotiates"; _mail $statuscode $i;;
	507) _echo $timevar $i $statuscode "Insufficient Storage"; _mail $statuscode $i;;
	509) _echo $timevar $i $statuscode "Bandwidth Limit Exceeded"; _mail $statuscode $i;;
	510) _echo $timevar $i $statuscode "Not Extended"; _mail $statuscode $i;;
esac

# 4  
Old 03-19-2011
Hi danmero

Its look good but i have some doubt in that


Code:
#!/bin/bash
timevar=$(date +%d-%m-%Y_%H.%M.%S) #-- > Storing Date and Time in a Variable
get_contents=`cat /urls.txt` #-- > Getting content of website from file. Note the file should not contain any http:// as its already been taken care of
######### Next Section Does all the processing #########
function _echo () 
{
    echo $1 $2 $3 $4 >> /log.txt
}
function _mail () 
{
    echo "Status $1 found" | mail -s "Check of $2 failed" 07anis@gmail.com
}
for i in $get_contents
do
statuscode=`curl -connect-timeout 30 -w “totaltime:%{time_total}\n” -s -I -L http://$i | awk '{for(i = 1; i<=NF; i++) if($i=="“totaltime:0.000n”“totaltime:0.000n”HTTP/1.1") print $(i+1);}'`

case $statuscode in
    200) _echo $timevar $i $statuscode "okay"; _mail $statuscode $i;;
    201) _echo $timevar $i $statuscode "created";;
    202) _echo $timevar $i $statuscode "Accepted";;
    203) _echo $timevar $i $statuscode "Non-Authoritative Information";;
    204) _echo $timevar $i $statuscode "No Content";;
    205) _echo $timevar $i $statuscode "Reset Content";;
    206) _echo $timevar $i $statuscode "Partial Content";;
    207) _echo $timevar $i $statuscode "Multi-Status";;
    226) _echo $timevar $i $statuscode "IM Used";;
    300) _echo $timevar $i $statuscode "Multiple choices";;
    301) _echo $timevar $i $statuscode "Moved Permanently";;
    302) _echo $timevar $i $statuscode "found";;
    303) _echo $timevar $i $statuscode "See Other";;
    304) _echo $timevar $i $statuscode "Not Modified";;
    305) _echo $timevar $i $statuscode "Use Proxy";;
    306) _echo $timevar $i $statuscode "UnUsed";;
    307) _echo $timevar $i $statuscode "Temporary Redirect";;
    400) _echo $timevar $i $statuscode "Bad Request"; _mail $statuscode $i;;
    401) _echo $timevar $i $statuscode "Unauthorized"; _mail $statuscode $i;;
    402) _echo $timevar $i $statuscode "Payment Required"; _mail $statuscode $i;;
    403) _echo $timevar $i $statuscode "Forbidden"; _mail $statuscode $i;;
    404) _echo $timevar $i $statuscode "Page Not Found"; _mail $statuscode $i;;
    405) _echo $timevar $i $statuscode "Method Not Allowed"; _mail $statuscode $i;;
    406) _echo $timevar $i $statuscode "Not Acceptable"; _mail $statuscode $i;;
    407) _echo $timevar $i $statuscode "Proxy Authentication Required"; _mail $statuscode $i;;
    408) _echo $timevar $i $statuscode "Request Timeout"; _mail $statuscode $i;;
    409) _echo $timevar $i $statuscode "Conflict"; _mail $statuscode $i;;
    410) _echo $timevar $i $statuscode "Gone"; _mail $statuscode $i;;
    411) _echo $timevar $i $statuscode "Length Required"; _mail $statuscode $i;;
    412) _echo $timevar $i $statuscode "Precondition Failed"; _mail $statuscode $i;;
    413) _echo $timevar $i $statuscode "Request Entity Too Large"; _mail $statuscode $i;;
    414) _echo $timevar $i $statuscode "Request-URI Too Long"; _mail $statuscode $i;;
    415) _echo $timevar $i $statuscode "Unsupported Media Type"; _mail $statuscode $i;;
    416) _echo $timevar $i $statuscode "Requested Range Not Satisfiable"; _mail $statuscode $i;;
    417) _echo $timevar $i $statuscode "Expectation Failed"; _mail $statuscode $i;;
    422) _echo $timevar $i $statuscode "Unprocessable Entity"; _mail $statuscode $i;;
    423) _echo $timevar $i $statuscode "Locked"; _mail $statuscode $i;;
    424) _echo $timevar $i $statuscode "Failed Dependency"; _mail $statuscode $i;;
    425) _echo $timevar $i $statuscode "Unordered Collection"; _mail $statuscode $i;;
    426) _echo $timevar $i $statuscode "Upgrade Required"; _mail $statuscode $i;;
    444) _echo $timevar $i $statuscode "No Response"; _mail $statuscode $i;;
    449) _echo $timevar $i $statuscode "Retry With"; _mail $statuscode $i;;
    450) _echo $timevar $i $statuscode "Blocked by Windows Parental Controls"; _mail $statuscode $i;;
    499) _echo $timevar $i $statuscode "Client Closed Request"; _mail $statuscode $i;;
    500) _echo $timevar $i $statuscode "Internal Server Error"; _mail $statuscode $i;;
    501) _echo $timevar $i $statuscode "Not Implemented"; _mail $statuscode $i;;
    502) _echo $timevar $i $statuscode "Bad Gateway"; _mail $statuscode $i;;
    503) _echo $timevar $i $statuscode "Service Unavailable"; _mail $statuscode $i;;
    504) _echo $timevar $i $statuscode "Gateway Timeout"; _mail $statuscode $i;;
    505) _echo $timevar $i $statuscode "HTTP Version Not Supported"; _mail $statuscode $i;;
    506) _echo $timevar $i $statuscode "Variant Also Negotiates"; _mail $statuscode $i;;
    507) _echo $timevar $i $statuscode "Insufficient Storage"; _mail $statuscode $i;;
    509) _echo $timevar $i $statuscode "Bandwidth Limit Exceeded"; _mail $statuscode $i;;
    510) _echo $timevar $i $statuscode "Not Extended"; _mail $statuscode $i;;
esac
done


Quote:
echo $1 $2 $3 $4 >> /log.txt
how it will working in this script?? can u pls explain for my understanding.


With Regards
Anish Kumar.V
# 5  
Old 03-19-2011
Quote:
Originally Posted by anishkumarv
how it will working in this script?? can u pls explain for my understanding.
Code:
function _echo () 
{
    echo $1 $2 $3 $4 >> /log.txt
}
.....
case $statuscode in
	200) _echo $timevar $i $statuscode "okay";;
.....

You have to take a look over bash manual for functions and arguments.
# 6  
Old 03-19-2011
hi danmero,

ya thanks alot for your suggestion and replies,

With Regards
Anish Kumar.V
# 7  
Old 03-19-2011
Inspired from Danero's code with some modif (ksh + building a parameter file + adding function _get_param ) i didn't try it so it may requires some little adaptation or fix.

Code:
#!/usr/bin/ksh

PARAMFILE=status.cfg

cat <<-EOF >$PARAMFILE
200:okay:M
201:created
202:Accepted
203:Non-Authoritative Information
204:No Content
205:Reset Content
206:Partial Content
207:Multi-Status
226:IM Used
300:Multiple choices
301:Moved Permanently
302:found
303:See Other
304:Not Modified
305:Use Proxy
306:UnUsed
307:Temporary Redirect
400:Bad Request:M
401:Unauthorized:M
402:Payment Required:M
403:Forbidden:M
404:Page Not Found:M
405:Method Not Allowed :M
406:Not Acceptable:M
407:Proxy Authentication Required:M
408:Request Timeout:M
409:Conflict:M
410:Gone:M
411:Length Required:M
412:Precondition Failed:M
413:Request Entity Too Large:M
414:Request-URI Too Long:M
415:Unsupported Media Type :M
416:Requested Range Not Satisfiable:M
417:Expectation Failed:M
422:Unprocessable Entity:M
423:Locked:M
424:Failed Dependency:M
425:Unordered Collection:M
426:Upgrade Required:M
444:No Response:M
449:Retry With:M
450:Blocked by Windows Parental Controls:M
499:Client Closed Request:M
500:Internal Server Error:M
501:Not Implemented:M
502:Bad Gateway:M
503:Service Unavailable:M
504:Gateway Timeout:M
505:HTTP Version Not Supported:M
506:Variant Also Negotiates:M
507:Insufficient Storage:M
509:Bandwidth Limit Exceeded:M
510:Not Extended:M
EOF

echo "BP "
STA=
ML=
MSG=
_get_param(){
        awk -F: -v c="$1" '$0~c{print $1,($3=="M")?Y:N,$2}' $PARAMFILE | read STA ML MSG
}

timevar=$(date +%d-%m-%Y_%H.%M.%S) #—– > Storing Date and Time in a Variable
get_contents=`cat ./urls.txt`  #—- > Getting content of website from  file. Note the file should not contain any http:// as its already been  taken care of
######### Next Section Does all the processing #########
_echo(){
        echo $1 $2 $3 $4  >> /log.txt
}
_mail(){
        echo "Status $1 found" | mail -s "Check of $2 failed" 07anis@gmail.com
}

for i in $get_contents
do
statuscode=`curl –connect-timeout 30 -w “totaltime:%{time_total}\n” -s  -I -L http://$i | awk '{for(i = 1; i<=NF; i++)  if($i=="“totaltime:0.000n”“totaltime:0.000n”HTTP/1.1") print $(i+1);}'`

_get_param $statuscode
_echo $timevar $i $statuscode $MSG
[[ $ML == Y ]] && _mail $statuscode $i

done
rm $PARAMFILE

Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to block first bash script until second bash script script launches web server/site?

I'm new to utilities like socat and netcat and I'm not clear if they will do what I need. I have a "compileDeployStartWebServer.sh" script and a "StartBrowser.sh" script that are started by emacs/elisp at the same time in two different processes. I'm using Cygwin bash on Windows 10. My... (3 Replies)
Discussion started by: siegfried
3 Replies

2. Shell Programming and Scripting

Optimizing script to reduce execution time

AFILENAME=glow.sh FILENAME="/${AFILENAME}" WIDTHA=$(echo ${FILENAME} | wc -c) NTIME=0 RESULTS=$(for eachletter in $(echo ${FILENAME} | fold -w 1) do WIDTHTIMES=$(awk "BEGIN{printf... (5 Replies)
Discussion started by: SkySmart
5 Replies

3. Shell Programming and Scripting

Bash - delete from csv all the row if the first column is length >

Hi guys, i have a csv file like: USERID;COG;DESCR;FIL;OFF user001;user;test1;001;A01 user002;user;test2;002;A02 user0003;user;test3;003;A03 user004;user;test4;004;A04 user0005;user;test5;005;A05 etc.. I need to read line for line and, if value of first column is > 7 char (in this example... (4 Replies)
Discussion started by: kamose
4 Replies

4. Shell Programming and Scripting

Reduce the number of lines in script

Hello All, I have created a script which will show the errors from a log file in between a particular section. v1=$(sed -n "/Main Report/,/Main Report End/p" input | grep -i 'Unable to find' v2=$(sed -n "/Main Report/,/Main Report End/p" input | grep -i 'Unable to add' if then echo... (5 Replies)
Discussion started by: Vikram_Tanwar12
5 Replies

5. Shell Programming and Scripting

Automation script to reduce the installation time

DELETED. (0 Replies)
Discussion started by: vasuvv
0 Replies

6. Shell Programming and Scripting

How to make bash wrapper for java/groovy program with variable length arguments lists?

The following bash script does not work because the java/groovy code always thinks there are four arguments even if there are only 1 or 2. As you can see from my hideous backslashes, I am using cygwin bash on windows. export... (1 Reply)
Discussion started by: siegfried
1 Replies

7. Shell Programming and Scripting

How to reduce the length of records in a file?

I have a file with 400 characters How can I create another file with only a portion of them (like 300 within 400) and get rid of the rest? Thanks (5 Replies)
Discussion started by: fafchi
5 Replies

8. Shell Programming and Scripting

need inputs on how i can change my script to reduce amount of time the script takes

HI , I have a list1 which consists of data that i have to search and a list2 which has the files that need to be searched .So basically i am using list1 on list2 to see if list1 data is present if found replace it .I have written the code using foreach loop for each list .This is taking the... (1 Reply)
Discussion started by: madhul2002
1 Replies

9. Shell Programming and Scripting

how to reduce a length in a file?

i want to reduce a length in the file called text in the file im having 10 byte length. want to reduce it to 9 byte length for all lines. (5 Replies)
Discussion started by: laknar
5 Replies
Login or Register to Ask a Question