Need to understand the script pls help


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Need to understand the script pls help
# 1  
Old 03-17-2011
Need to understand the script pls help

Can u please explain what it is doing

Code:
#!/bin/sh
fullyear=`/home/local/bin/datemmdd 1`"."`date +%Y`
uehist=/u05/home/celldba/utility/ue/prod/history
echo $fullyear
cd $uehist
ls -ltr pwroutages.master.$fullyear* | awk '{print $9}' > /u01/home/celldba/tmp/pwroutages_master_all_tmp
while read x;
do
cat $x >> $uehist/pwroutages.master_all.$fullyear;
rm -f $x
done < /u01/home/celldba/tmp/pwroutages_master_all_tmp
rm /u01/home/celldba/tmp/pwroutages_master_all_tmp

Moderator's Comments:
Mod Comment
Please use code tags when posting data and code samples!

Last edited by vgersh99; 03-17-2011 at 12:48 PM.. Reason: code tags, please!
# 2  
Old 03-18-2011
The last 8 lines could be replaced with a shorter
Code:
ls -rt ${uehist}/pwroutages.master.${fullyear}* | while read x
do
cat $x >>${uehist}/pwroutages.master_all.${fullyear} && rm -f $x
done

Mainly what it does is:

It takes all the files matching ${uehist}/pwroutages.master.${fullyear}* absolute names from the older to the newer (-rt = -reverse time),

and concatenate the content of each and every file into the file ${uehist}/pwroutages.master_all.${fullyear}

After every successfull concatenation, it deletes the corresponding ${uehist}/pwroutages.master.${fullyear}* file
# 3  
Old 03-18-2011
Thank you very much sir, appreciate your help
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Help me understand this script

#!/bin/awk -f BEGIN {i=1;file="modified.txt"} { if ($0 !~ /^DS:/) {print $0 >> file} else { if ($0 ~ /^DS:/) {print "DS: ",i >> file;if (i==8) {i=1} else {i++}}; } } END {gzip file} Can someone explain to me how this above script works, I got it from a friend but not able... (3 Replies)
Discussion started by: Kamesh G
3 Replies

2. Shell Programming and Scripting

Need help to understand the below shell script

Please help me to understand the below 3 lines of code.execute shell in jenkins 1)APP_IP=$( docker inspect --format '{{ .NetworkSettings.Networks.'"$DOCKER_NETWORK_NAME"'.IPAddress }}' ${PROJECT_NAME_KEY}"-CI" ) 2)HOST_WORKSPACE=$(echo ${WORKSPACE} | sed... (1 Reply)
Discussion started by: naresh85
1 Replies

3. Shell Programming and Scripting

Can't understand script output

New to korn shel1 and having an issue. The following is suppose to read the parameter values from files in a source directory and then pass them on to a log file in a different directory, The ArchiveTracker scripts is suppose to call the parameterreader script to exact the parameter values and... (3 Replies)
Discussion started by: bayouprophet
3 Replies

4. Shell Programming and Scripting

Help to understand a script

Hello world! Can someone please explain me how this code works? I'ts supposed to find words in a dictionary and show the anagrams of the words. { part = word2key($1) data = $1 } function word2key(word, a, i, x, result) { x = split(word, a, "") asort(a) ... (1 Reply)
Discussion started by: jose2802
1 Replies

5. Shell Programming and Scripting

Need help to understand this small script

Hi Guys, I need to understand below scipt:- -bash-3.00$ cat rsync-copy.ksh #!/usr/5bin/ksh batch <<%EOF% echo "/usr/local/bin/rsync --rsync-path=/usr/local/bin/rsync -a --stats /usr/openv/ /OpenvBCK" > openv.LOG # CG /usr/local/bin/rsync ... (6 Replies)
Discussion started by: manalisharmabe
6 Replies

6. UNIX for Dummies Questions & Answers

Need to understand shell script

Hello, Can someone please help me understand the shell script below for installing Jboss EAP 6? It is from jboss-as-standalone.sh, what does the highlighted code mean? # Load Java configuration. && . /etc/java/java.conf export JAVA_HOME Thanks! (4 Replies)
Discussion started by: learnix
4 Replies

7. Shell Programming and Scripting

Understand script formte

Hi i have one script and i am running it but not getting current output so i want to understand how to input in the script. when i do help then i am getting below massage thanks got it (1 Reply)
Discussion started by: asavaliya
1 Replies

8. Shell Programming and Scripting

Help to understand the script

Hi All; Is there anybody can explain this script please? trap 'C_logmsg "F" "CNTL/c OS signal trapped, Script ${G_SCRIPTNAME] terminated"; exit 1' 2 trap 'C_logmsg "F" "Kill Job Event sent from the Console, Script ${G_SCRIPTNAME] terminated"; exit 1' 15 (3 Replies)
Discussion started by: thankbe
3 Replies

9. Shell Programming and Scripting

Can't understand the script

I am relatively new to Shell Scripting. I can't understand the following two scripts. Can someone please spare a minute to explain? 1) content s of file a are (021) 654-1234 sed 's/(//g;s/)//g;s/ /-/g' a 021-654-1234 2)cut -d: -f1,3,7 /etc/passwd |sort -t: +1n gives error (3 Replies)
Discussion started by: shahdharmit
3 Replies
Login or Register to Ask a Question