Deciphering the Code


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Deciphering the Code
# 8  
Old 05-22-2009
Quote:
Originally Posted by coyote1967
Oh cool thanks Jim. I might be back with more questions
OK more questions LOL
So what everybody is saying is that if [$# -lt 1]; then set /etc/ /etc/.save; fi
if the $# is less than 1 then set will show the variables in the /etc/ file? right??? then how does the /etc/.save come into play?
The next line in the code is almost like the one I just posted except that it says
if [$# -lt 2] then set $* /etc/.save; fi
So if the argument count is less than 2 then it will show the variables in the $*????? I know the "*" is a metacharacter but there again how or what is it doing to the /etc/.save file? This stuff is making my head spin. It seems way over my head and I am supposed to learn it. There are just too many special characters that doing different things at different times and it is confusing the hell out of me. I thought C++ was bad but this takes the cake.
# 9  
Old 06-04-2009
What in the world is trying to be done with this line of code. Can anybody help me decipher it. It goes like this
for f in 'cat $1/.savelist'

I think it is trying to execute the command but not sure what the f is in the beginning not to mention the for at the start of this line. Can anybody shed some light. Thanks Keith
# 10  
Old 06-05-2009
I guess you mean
Code:
for f in `cat $1/.savelist`

not
Code:
for f in 'cat $1/.savelist'

because there's a big difference between quotes and backticks.
What this does is read the values of the file '.savelist' in the directory specified at the command line ($1) into the variable 'f', looping over each one.
# 11  
Old 06-05-2009
Yes Pludi that is what I meant and at the time couldn't find the right key but I see it now. So your saying it is going to view everything in the directory and put it in the f file??Smilie

Not sure I understand it completely though
 
Login or Register to Ask a Question

Previous Thread | Next Thread

8 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Deciphering AWK code

Dear experts, I am a relative novice in the Unix and came across a very useful code that I regularly use for my research blindly. I am wondering if any of the professional members could kindly briefly explain to me what the code actually does? Many thanks in advance The script is awk... (4 Replies)
Discussion started by: arsalane
4 Replies

2. Programming

Deciphering a tag character string

I have a string, eg 7f30.3 and I want to store things in the following way npos = 7 decform = true width = 30 ndp = 3 I need to read each character one by one. I am coding in fortran but I can try to code it should answer be given in C in the above way. (2 Replies)
Discussion started by: kristinu
2 Replies

3. Shell Programming and Scripting

need help deciphering this if statement

I'm going through my bash book and came across this if statment. if *$)" ]; then the book says that the grep expression means "an initial dash followed by a digit" (which I understand) "optionally followed by one or more digits" That's the part I can't figure out -- I know the * is a... (8 Replies)
Discussion started by: Straitsfan
8 Replies

4. Programming

Some help with Perl please (deciphering)

I am trying to simplify the coding in a script I was given, but it was written 7-10 years ago and is pretty complicated. below is a tidbit, if someone can break it down for me I would appreciate it. sub ParseText { my ($line, $key, $value, $sub, $script); foreach $line (@_)... (0 Replies)
Discussion started by: callyvan
0 Replies

5. UNIX for Dummies Questions & Answers

Need help deciphering this

I'm reading about command substitutions and came across this little function in my book: function lsd { date=$1 ls -l |grep -i "^.\{42\}$date"|cut -c55- } it's a little example which is supposed to select files by modification date, given as an argument to the function. I... (3 Replies)
Discussion started by: Straitsfan
3 Replies

6. Shell Programming and Scripting

Deciphering strings or variable values

Hi, I have a script at the moment of which reads in simply what the latest version is within a folder i.e. v001, v002, v003 etc and then stores this latest version in a variable i.e. $LATEST would echo v003. I have then cut this string so that I only consider the 003 part. I would then like to... (3 Replies)
Discussion started by: cyberfrog
3 Replies

7. Shell Programming and Scripting

Help deciphering FTP get perl script

I found this very useful perl script that will check a remote ftp server, search for files of a specific time and get them. When I run the script it works, but it gave me the following error: Couldn't get filename_12-13-07.txt Bad file number What in this script would cause this? I know... (2 Replies)
Discussion started by: bbbngowc
2 Replies

8. Shell Programming and Scripting

Help deciphering script

There are files on a remote server with the file name ending in "mm-dd-yy.txt". The script I am running is: mls "Daily_Service_Text_File_*" /my/local/dir/Filelisting.txt nawk -F_ -f file.awk /my/local/dir/Filelisting.txt | sort -k1n | cut -f2- | tail -1 It worked up too "12-31-07.txt" but... (3 Replies)
Discussion started by: bbbngowc
3 Replies
Login or Register to Ask a Question