Little Trouble Understanding some code...


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Little Trouble Understanding some code...
# 1  
Old 10-30-2007
Little Trouble Understanding some code...

Couple of questions as I try to decipher someones code who left...

What would something coded like this do?

IFS=:
grep FIELD1 /Path/Path2/Param.fle | read LBL1 LBL2 USRID EADR SUBJ SERVERNAME CFGTBL DIR
ERR=0

Param.fle contents..
FIELD1:FEI::FIELD2:dATAFIELD BATCH:MAIN SERVER......etc..
# 2  
Old 10-30-2007
IFS=: makes a colon the default field separator. By grep FIELD1, the code only finds records with the word "FIELD1" in them, probably just one record.

Next, since IFS is a colon, each of the variables in the read statement will be assigned the value of the corresponding field in the file.
LBL1 will be the first field, ie., FIELD1
LBL2 will be the second FEI
and so on.

You now have several variables defined as the contents of the fields in one record from
Param.fle
# 3  
Old 10-31-2007
I got you up to LBL2, so then USRID is going to be blank because of the '::' after FEI which if I'm understanding correctly is null since there is nothing in between the colons?
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. What is on Your Mind?

I'm having trouble understanding what it is I need to do

Ok, thank you. Again I'm new to the programming thing, I'm just trying to figure out what exactly it is I need to do. How would I cash out bits? Numerous questions. I'm a dreamer. AI attempts to communicate with me regularly especially through unfinished apps that I'm assuming is my responsibility... (1 Reply)
Discussion started by: C-lo
1 Replies

2. Programming

Code trouble

I have a formula for figuring out relitive humidity but it will not compile the trouble is the double ** es= 6.11 * 10.0**(7.5*tc/(237.7+tc)) how do I enter in gcc format...?? thanks Eldon (6 Replies)
Discussion started by: eldondehart
6 Replies

3. Programming

Understanding Assembly Code

As the title suggests, I want to better understand the following assembly code: section .text global main ; must be declared for linker (gcc) main: ; tell linker entry point mov edx, len ; message length mov ecx, msg ; message to write... (2 Replies)
Discussion started by: Azrael
2 Replies

4. Shell Programming and Scripting

Trouble understanding shell scripting (mostly wsname)

Am still learning Scripting and I come across a build command that I don't really understand if /local/bin/wsname 2>/dev/null; then base="`/local/bin/wsname`" export base fi if ; then /local/bin/wsname exit 1 fi WSNAME="$base"/ can some one in light me to what... (1 Reply)
Discussion started by: Wpgn
1 Replies

5. Shell Programming and Scripting

Help with perl code understanding

Hi, I need to understand below perl code, can some one advise me. perl -MDate::Parse -e'BEGIN{$main::now=time;$main::old=(time-60*30)}' -nE'if(/^(\w+\s+\d+\s+\d+:\d+:\d+)/) {$t=str2time $1; $t > $old && $t < $now && print}' (1 Reply)
Discussion started by: learnbash
1 Replies

6. Programming

Understanding perl code

What is the difference between the two statements below? A: $a->{"$fruit"}->{"$color"}->{size} = $size B: $size = $a->{"$fruit"}->{"$color"}->{size} Please assist. Thanks! (0 Replies)
Discussion started by: onlinelearner02
0 Replies

7. Homework & Coursework Questions

trouble understanding file option and command line arguments

Hi, I am creating a program with the C language that simulates the WC command in Unix. My program needs to count lines, bytes and words. I have not added the code to count bytes and words yet. I am having trouble understanding what the file option/flag '-' does. I can not visualize how it moves... (1 Reply)
Discussion started by: heywoodfloyd
1 Replies

8. UNIX for Dummies Questions & Answers

Having trouble understanding this command: >foo<bar bc

Sometimes it works for me and sometimes I get this error: syntax error on line 1, teletype Basically I've got no idea whats going on, especially at the end of the command: bc Any help is appreciated (1 Reply)
Discussion started by: phunkypants
1 Replies

9. UNIX Desktop Questions & Answers

Understanding the code

hello all, May i know what is this "DEBUG_ME $DEBUG_CMD main" doing in the below code. I am confused with alias also "alias DEBUG_ME='#'". Thanks for your help. set -x alias DEBUG_ME='#' if ; then . /product/apps/informatica/v7/pc/ExtProc/debug.ksh "$1" fi # Declaring the... (1 Reply)
Discussion started by: Ariean
1 Replies

10. Shell Programming and Scripting

Need help in understanding thisperl code.

Can any body explains the under given lines of code i have difficulties in understanding it, my $errorlog = "/var/log/controler.log"; &initLanguage($language); &launchCbox(); sub launchCbox { ... (1 Reply)
Discussion started by: Raheel Hassan
1 Replies
Login or Register to Ask a Question