Help in understanding the following commands


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Help in understanding the following commands
# 1  
Old 10-16-2009
Help in understanding the following commands

Hi ,

Please help me in understanding the below commands

temp="$dirname.temp.cc.$$"
This will eliminate any trailing white spaces???

k=$(grep -cvE " |\+|-|0|1|\f" $temp

if (substr(file,2,24) ~ /[0-9]{13,}/) {print "N" file} -- this is inside an awk script

Last edited by justchill; 10-16-2009 at 05:47 AM..
# 2  
Old 10-16-2009
Hi,

$$ stands for process id of the running process. To include this in a filename is a way of making the file or directory unique.

The second expression is missing a closing parenthesis. But it set k to the number of lines that do not contain the characters " ", "+", "-","0", "1" or formfeed. Whether the formfeed detection will work depends on your version of grep. If it doesn't then this code will also exclude lines that contain the character "f" from the count and that probably is not what was intended.

The third expression means if the 24 characters starting at position 2 in the variable "file" contain 13 or more digits then print the character "N" concatenated by the content of the variable "file" .

Last edited by Scrutinizer; 10-16-2009 at 06:05 AM..
# 3  
Old 10-16-2009
hey thanks very much...

if (substr(file,2,24) ~ /[0-9]{13,}/) {print "N" file}

please let me know if my understanding of the above line is correct.


the substr takes the charcters 2 to 24 inclusive, and checks 13 consecutive digits??
if its present, then print precede "N"to that line
# 4  
Old 10-16-2009
Almost correct. 13 or more digits.
# 5  
Old 10-16-2009
thanks very much!!
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Need your help in understanding this

Hi, I found this in a script and I would like to know how this works Code is here: # var1=PART1_PART2 # var2=${var1##*_} # echo $var2 PART2 I'm wondering how ##* makes the Shell to understand to pick up the last value from the given. (2 Replies)
Discussion started by: sathyaonnuix
2 Replies

2. Red Hat

Understanding Results from df and du commands

Good day every one. When a use df -h comand on my read hat linux server i get something like this: /dev/mapper/Vg02-Lv19 30G 29G 145M 100% /app Then when i do du -sh /app/ i get 12G /app/ For me it is meaning that only 12G was used on /app partition. How can i see where are... (9 Replies)
Discussion started by: cgege
9 Replies

3. Shell Programming and Scripting

Understanding Benchmarks

I need a little clarification in understanding why there would be a need for a benchmark file when used with a backup script. Logically thinking would tell me that the backups itself(backuptest.tgz) would have the time created and etc. So what would be the purpose of such a file: touch... (6 Replies)
Discussion started by: metallica1973
6 Replies

4. AIX

HACMP: difference between 'cl' commands and 'cli' commands

Hi all, I'm new in this forum. I'm looking for the difference between the HACMP commands with the prefix "cl" and "cli". The first type are under /usr/es/sbin/cluster/sbin directory and the second are under /usr/es/sbin/cluster/cspoc directory. I know that the first are called HACMP for AIX... (0 Replies)
Discussion started by: peppix
0 Replies

5. UNIX for Dummies Questions & Answers

understanding {%/*}/

Hi Gurus: I am trying to understand the following line of code.I did enough of googling to understand but no luck.Please help me understand the follow chunk of code: X=$0 MOD=${X%/*}/env.ksh X is the current script from which I am trying to execute. Say if X=test.ksh $MOD is echoing :... (3 Replies)
Discussion started by: vemana
3 Replies

6. Shell Programming and Scripting

need help understanding mv

I just started shell coding and I'm a bit confused on how 'mv' works can someone explain to me how it works and if i did this correctly. Thanks. echo "Enter Name of the first file:" read file1 #echo $file1 if ; then echo "Sorry, file does not exist." exit 1 ... (16 Replies)
Discussion started by: taiL
16 Replies

7. UNIX for Dummies Questions & Answers

Understanding 2>&1

Hi, I have this line in a script: if mt -f /dev/nst0 rewind > /tmp/status_nst0.log 2>&1 ; then What does the 2>&1 mean? I think the line is saying that after rewinding the device if the log file does not exist then execute the code but I do not understand the contribution of the 2>&1.... (2 Replies)
Discussion started by: mojoman
2 Replies

8. Shell Programming and Scripting

Can BASH execute commands on a remote server when the commands are embedded in shell

I want to log into a remote server transfer over a new config and then backup the existing config, replace with the new config. I am not sure if I can do this with BASH scripting. I have set up password less login by adding my public key to authorized_keys file, it works. I am a little... (1 Reply)
Discussion started by: bash_in_my_head
1 Replies

9. Programming

code that reads commands from the standard i/p and executes the commands

Hello all, i've written a small piece of code that will read commands from standard input and executes the commands. Its working fine and is execting the commands well. Accepting arguments too. e.g #mkdir <name of the directory> The problem is that its not letting me change the directory i.e... (4 Replies)
Discussion started by: Phrozen Smoke
4 Replies
Login or Register to Ask a Question