Meaning of script with echo, -d, -f1, -f2


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Meaning of script with echo, -d, -f1, -f2
# 8  
Old 02-20-2014
Quote:
Originally Posted by DK2014
I have about 20 script files & all of them begins with "#!/usr/bin/ksh", this means its "The Korn shell".
Correct. The first line states the command processor, because under Unix there tend to be several. Korn shell, Bourne shell, bash, C shell, ...

Quote:
Originally Posted by DK2014
I don't have access to the unix server as its on my client place & I just have to work on the test of the scripting part.
Understood, but how are you going to test if your script does the same on your box as the Unix script does on the Unix box? My envy because of your job is quite limited, so to say. ;-)

Quote:
Originally Posted by DK2014
In order to find the meaning of all the commands & other things line variables, functions etc, please let me know what should i search on internet (some key words etc which can help me to quickly find these cmds etc)
In the top box of this forums page is a menu point "Man Pages" where you can read the man pages even if you do not have a system of your own.

I'd suggest getting you a Linux-"Live-CD" (you can download one freely from the internet), put that on a USB-stick and boot some spare PC with that, which will give you a working Linux environment without installing anything. Unix and Linux is not the same but so close that you can use it interchangeably for your purpose. Linux uses "bash" instead of Korn shell per default, but you can isntall a ksh even persistently if your stick is big enough (bigger than 4G).

If you want access to a more lasting solution I'd suggest installing VirtualBox (VMWare, ....) and install a Linux there. You can boot this virtual machine in a window and play around and/or even access the internet with your system acting as bridge. Beware, though: using Unix is - for most Windows users - rather addictive. :-) It might well be that after some time you isntall Linux andmove Windows to a virtual box, finally to remove Windows altogether.

If anything is unclear when you read the man pages, just search this forum or ask here if you can't find it. We rarely bite newbies.

I hope this helps.

bakunin
I hope this helps.
# 9  
Old 02-21-2014
Thanks a lot bakunin.

This definitely helps Smilie

---------- Post updated at 11:13 AM ---------- Previous update was at 02:36 AM ----------

Hi bakunin,

Can you help me in understanding the below 2 lines of code,
Code:
     SUBJECT="$ENV -- Jobs in JE status that need attention"
     COMMENTS=`echo $COMMENTS | sed s/#/\ /g`

In the 1st line what is the meaning of "--" & how it gets club with $ENV.
In the 2nd line what is the meaning of sed s/#/\ /g`.

Thanks again for your time.

Last edited by Franklin52; 02-24-2014 at 09:36 AM.. Reason: Please use code tags for data and code samples
# 10  
Old 02-24-2014
Quote:
Originally Posted by DK2014
Code:
COMMENTS=`echo $COMMENTS | sed s/#/\ /g`

In the 2nd line what is the meaning of "sed s/#/\ /g`".

This one is easy: "sed" is a programmable text filter. In this case it replaces every "#" with what follows after "\" (here it looks like a space, but it could be a tab either in the original) in the content of a variable "COMMENTS". The result of this substitution is then fed to the variable "COMMENTS" again. Let me add that it is simply idiotic to do it this way, because "#" is indeed the comment character (like "//" in C++), but sometimes it is used in quoted strings. On the folliwng the script would most probably do something you don't want to have done:

Code:
command1 # this is a comment
echo "but this: # is not"


Quote:
Originally Posted by DK2014
[code]
SUBJECT="$ENV -- Jobs in JE status that need attention"

In the 1st line what is the meaning of "--" & how it gets club with $ENV.
"ENV" is a variable where the path/filename to a configuration file for the shell is stored. In most cases something like:

Code:
ENV="~/.kshrc"
export ENV

is part of your profile. This means that the login shell, when it starts, should search for a file in your HOME directory ("~") named ".kshrc" and source that in. Usually "~/.kshrc" contains some settings you want your shell to have.

Here, a variable "SUBJECT" is set to contain the content variable "ENV" plus the fixed string " -- Jobs in JE status that need attention" concatenated. "--" has no special meaning here. This too is most probably not doing what it is supposed to do, but guessing what it should do is beyond my abilities.

I hope this helps.

bakunin
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Meaning of =~ in shell script

Please let me understand the meaning of following line in unix bash scripting .is =~ means not equal to or equal to . if ]; then echo -e "pmcmd startworkflow -sv ${INTSERV} -d ${INFA_DEFAULT_DOMAIN} -uv INFA_DEFAULT_DOMAIN_USER" \ "-pv INFA_DEFAULT_DOMAIN_PASSWORD -usdv... (2 Replies)
Discussion started by: harry00514
2 Replies

2. Shell Programming and Scripting

What is the meaning of ## in UNIX shell script?

Hi All, I am new to unix shell scripting and I was documenting one of the unix script and encountered below statements - for ii in `ls -1rt /oracle/admin/MARSCOPY/ext_files/fpm-ifpm/*.small.txt | tail -1 | awk '{print $1}'` do smallssim=${ii##/oracle/admin/MARSCOPY/ext_files/fpm-ifpm/}... (2 Replies)
Discussion started by: shuklajayb4
2 Replies

3. UNIX for Dummies Questions & Answers

UNIX Script - snipet meaning?

What would the below code snippet mean? my ($_configParam, $_paramValue) = split(/\s*=\s*/, $_, 2); $configParamHash{$_configParam} = $_paramValue; (2 Replies)
Discussion started by: MaKha
2 Replies

4. UNIX for Dummies Questions & Answers

Meaning of awk script

what does this mean? awk '!a||a>$1 {a=$1} END {for (i in a) print a,i}' file (6 Replies)
Discussion started by: osama ahmed
6 Replies

5. Shell Programming and Scripting

Whats the meaning of set -e inside the script

Hi, I would like to ask about the meaning or purpose of set -e in the script bash, Does it mean if a wrong command in the script it will close or exit the script without continuation thats what happen if i set it in the terminal. Thanks in advance (3 Replies)
Discussion started by: jao_madn
3 Replies

6. Shell Programming and Scripting

printf/echo in a second script

This may be little confusing. I have Script1, which pulls data from the system and creates another script(lets say script2). While I run script1 I need to add printf/echo statements for script2, so that when I run script2 I see those statement. eg: script1 765 printf " display frame-$1 timeoffset... (2 Replies)
Discussion started by: miltonrods
2 Replies

7. Shell Programming and Scripting

echo prints nothing-shell script

could anyone tell me why when i execute the following script, echo returns blank set k = 1 echo $k (9 Replies)
Discussion started by: saman_glorious
9 Replies

8. UNIX for Dummies Questions & Answers

meaning of script

hello every one i want to know meaning of following line INST_PARA=$HOME/install/Install.Para SAVEMEDIUM=`awk '$2=="ArchiveSave"{print$4}' $INST_PARA` (4 Replies)
Discussion started by: kaydream
4 Replies

9. Shell Programming and Scripting

Using echo to create a script

Hello all, I want to be able to create a script on the fly from another script by echoing lines into a file, but am running into difficulty, as it isn't working right. What am I doing wrong? echo "for i in `grep $FRAME /root_home/powermt.sort.fil |awk '{print $7}'`" > pvtimout_set.sh... (5 Replies)
Discussion started by: LinuxRacr
5 Replies

10. Shell Programming and Scripting

Meaning of this line in script

Can anyone explain me the meaning of line #2 in these lines of shell script: if ; then ${EXPR} " ${MACTIONS } " : ".* ${ACTION} " >/dev/null 2>&1 || die "$USAGE" else Sorry in case this is a trivial thing (I am not an expert in this). (3 Replies)
Discussion started by: radiatejava
3 Replies
Login or Register to Ask a Question