help me to understand this code


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers help me to understand this code
# 1  
Old 11-04-2014
help me to understand this code

Hi guys can you please help me to understand this code .
Code:
tmpArray=(${line//=/ })


Moderator's Comments:
Mod Comment Please next time open a new thread in the appropriate forum and use code tags

Last edited by Scrutinizer; 11-04-2014 at 02:16 AM.. Reason: code tags
# 2  
Old 11-04-2014
It's removing all occurrences of "=" in $line and then assigns the result to tmparray. Read man bash on Parameter Expansion / Pattern substitution.
This User Gave Thanks to RudiC For This Post:
# 3  
Old 11-04-2014
thank you
# 4  
Old 11-04-2014
can you please help me with the unix code

can you please help me understand this code
Code:
tmpArray=(${line//=/ })
field[${tmpArray[0]}]=${tmpArray[1]}; 
done < test.conf

---------- Post updated at 06:35 AM ---------- Previous update was at 06:34 AM ----------

thank you Rudic and please do reply for this post also .
can you please help me understand this code
Code:
tmpArray=(${line//=/ })
field[${tmpArray[0]}]=${tmpArray[1]}; 
done < test.conf

---------- Post updated at 06:36 AM ---------- Previous update was at 06:35 AM ----------

thank you

Last edited by Franklin52; 11-04-2014 at 07:40 AM.. Reason: Please use code tags
# 5  
Old 11-04-2014
It's usually pointless to analyze an incomplete code snippet, so next time post an entire meaningful portion of a script. Anyhow:
Code:
field[${tmpArray[0]}]=${tmpArray[1]};       # create an associative array element with index t...[0] and value t...[1]
done < test.conf                            # redirect the do ... done loop's input to a file

This User Gave Thanks to RudiC For This Post:
# 6  
Old 11-04-2014
actually its in while loop .I'm new to this field so nt much deep knowledge abt this
the code is like this
Code:
 function fn_readfile()
 (
 xfile=$1
 while read line
 do
 tmpArray=(${line//=/ })
 filenme[${tmpArray[0]}]=${tmpArray[1]}
 done < $xfile
 )

---------- Post updated at 07:07 AM ---------- Previous update was at 07:00 AM ----------

actually its in while loop .I'm new to this field so nt much deep knowledge abt this
the code is like this
function fn_readfile()
(
xfile=$1
while read line
do
tmpArray=(${line//=/ })
filenme[${tmpArray[0]}]=${tmpArray[1]}
done < $xfile
)

Last edited by Don Cragun; 11-04-2014 at 08:05 AM.. Reason: Add CODE tags.
# 7  
Old 11-04-2014
I'd propose that with the info given above, you tell us what these lines do, and we eventually correct it.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

8 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Trying to understand a complex bit of code

Hi, To re-introduce myself, I'm a router guy trying to learn some scripting from the examples in my work place... In a ksh script, one of the script guys wrote the following and I am trying to understand it. I'm hoping someone can explain it to me. The script flow enters a case structure.... (5 Replies)
Discussion started by: Marc G
5 Replies

2. Shell Programming and Scripting

can't understand!

Hi All, can you please help me to figured out what's the meaning of this. ${SERVER_DATABASE} -b << EOF 2>>/dev/null THanks, (3 Replies)
Discussion started by: nikki1200
3 Replies

3. Shell Programming and Scripting

help can't understand the code

Hi All, Good day, i'm just wondering what is the meaning of this code? COUNT_EXTRACTED_FILE=`${ECHO_CMD} "${SE_IN_PATH}${SE_IN_FILE}" | ${AWK_CMD} -F"__" '{print $2}'` Thanks, -niks(newbie) (2 Replies)
Discussion started by: nikki1200
2 Replies

4. Programming

Need help with this c++ source code! DOnt understand what some stuff mean.

Okay so I am just starting programming c++. I just started started to red "C++ for Dummies yesterday and theres a lot of things I do not understand from this book and this source code especially. I will first post the full source code and then post questions about certain thing, usually what they... (2 Replies)
Discussion started by: orszhak
2 Replies

5. Shell Programming and Scripting

Need help to understand Awk code.

Hi Guys, Can someone please explain this code to me. I could figure out it's adding and comparing two fields but I am not sure which ones. sort -t"|" -k3.1 /tmp/mpcashqc.xtr| awk -F"|" '{CHECKAMT+=$3;BATCHTOT=$4;\ items++}END{for(i in CHECKAMT) if (CHECKAMT!=BATCHTOT)... (6 Replies)
Discussion started by: nua7
6 Replies

6. UNIX for Dummies Questions & Answers

unable to understand a awk code

i am not able to understand the following code for awk: $awk -F"|" '{ kount++} >END { for (desig in kount) > print desig,kount }' emp.list the input file i.e. emp.list is :: 3432| p.k.agrwal |g.m |sales 4566|g.l.sharma |director|production 3433|r shah | g.m | production... (1 Reply)
Discussion started by: streetfi8er
1 Replies

7. UNIX for Advanced & Expert Users

Code Understand ?

Hey, Could you explain me what this code is doing ? For example: $i has value 9 $1 is the name of the file say FILEBkUp while do if $1.`/bin/expr $i - 1` ] then mv -f $1.`/bin/expr $i - 1` $1.$i fi i=`/bin/expr $i - 1` done Thanks... (2 Replies)
Discussion started by: varungupta
2 Replies

8. Shell Programming and Scripting

perl - understand process status and continue the code execution

Hello, I need advice on how to check if started processes are finished in perl, here's explanation : OS is RHEL 4, perl -v = "This is perl, v5.8.0 built for i386-linux-thread-multi" The logic of the script : #!/usr/bin/perl use warnings; $param1 = $ARGV; $param2 = $ARGV; $param3 =... (2 Replies)
Discussion started by: sysgate
2 Replies
Login or Register to Ask a Question