Need help understanding script command

Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Need help understanding script command
# 1  
Old 01-12-2009
Need help understanding script command

We use a UNIX-based system (Lawson) at work and I was given this command to request a data extract from the db admin. The only thing I really understand is the last line as it appears to be joining the files created from the first three lines into one. Is there anyone who can help me breakdown the rest of the code. I assume "find" means exactly what it states and I think "grep" is extracting whatever is found. But what about the rest of the syntax in red, green and blue. And what does "/tmp" mean?

find /opt/app/lawprod/ \* -exec ls -l {} \; |grep Oct | grep -v " 200" > /tmp/oct
find /opt/app/lawprod/ \* -exec ls -l {} \; |grep Nov | grep -v " 200" > /tmp/nov
find /opt/app/lawprod/ \* -exec ls -l {} \; |grep Dec | grep -v " 200" > /tmp/dec
cat /tmp/oct /tmp/nov /tmp/dec > /tmp/oct-dec

Thank you.
# 2  
Old 01-12-2009
Its looking for files in the directory /opt/app/lawprod/ if the date is Oct them it put the results in the /tmp/oct

same for Nov and Dec.

then puts all the results from Oct, Nov and Dec into one file /tmp/oct-dec

/tmp is just a "Temporary" directory that occasionally gets cleared out. You use it to create files you dont need to keep forever.
# 3  
Old 01-12-2009
Thanks Ikon for helping clarify. I knew it was supposed to be looking for files that have changed, I was just curious to learn a little behind the syntax for my own understanding. I took a Linux course a number of years back and can remember using the cat and grep commands, among a few others.

If you don't mind, what do the \* -exec ls -l {} \; and -v " 200" part of the command specify? I saw online that "ls -l" is used to list directory contents in long list format and found something on "-exec" and the "-v" switch for grep, but I'm not sure I understand fully they mean. I'm guessing the output files might be of help, but I haven't received them as of yet.

Thanks again.

# 4  
Old 01-12-2009
This executes ls -l for each file "*" that it finds. So it give the file details filename, file size, etc...
-exec ls -l {} \;

this list the lines that DO NOT have " 200" in them. See example below.
-v " 200"

# cat test.log
John Smith
Bill Smith
Jack Brown
James Brown
Jill Smith
# cat test.log | grep Smith
John Smith
Bill Smith
Jill Smith
# cat test.log | grep -v "Smith"
Jack Brown
James Brown

# 5  
Old 01-13-2009
Ah, I see now. Thanks for providing the example. It makes it much easier to understand. Now I'm wondering why they are excluding anything with 200, but I will pose that question to the DBA.

Thanks again for your help!
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Help understanding what this ls -l command is checking in a script

Hello, we have a script that has the two following lines: ssh -qno StrictHostKeyChecking=no -o ConnectTimeout=1 user@IP 'ls -l /home/opsmgrsvc >/dev/null 2>&1' > /dev/null 2>&1 status="$(echo $?)" I can't understand what these two lines are doing? When I execute the first line nothing... (6 Replies)
Discussion started by: greavette
6 Replies

2. UNIX for Dummies Questions & Answers

understanding sed command

Hi Friends, I need a small help in understanding the below sed command. $ cat t4.txt 1 root 1 58 0 888K 368K sleep 4:06 0.00% init 1 root 1 58 0 888K 368K sleep 4:06 0.00% init last $ sed 's/*$//' t4.txt 1 root 1 58 0 888K ... (3 Replies)
Discussion started by: forroughuse
3 Replies

3. UNIX for Dummies Questions & Answers

Understanding nm command output

After running nm command on any object file from out put can we get to know that wheather a symbol is a call to a function or definition of function ? I am searching a class and function definitions inside many .so files. I have 3 files which contain the symbol but I don't know wheather they... (2 Replies)
Discussion started by: yatrik007
2 Replies

4. Shell Programming and Scripting

Understanding 'find' command

I want to understand what does this command do:confused::confused: find . \( -type f -o -type 1 \) Plz someone explain me ! Thanks much in advance!! (2 Replies)
Discussion started by: sears
2 Replies

5. Solaris

Understanding 'du' command

Hi I have a questions related 2 commands : 'du' and 'ls'. Why is the difference between output of 'du' and 'ls' cmd's ? Command 'du' : ------------------ jakubn@server1 /home/jakubn $ du -s * 4 engine.ksh 1331 scripts 'du -s *' ---> shows block count size on disk (512 Bytes... (5 Replies)
Discussion started by: presul
5 Replies

6. UNIX for Dummies Questions & Answers

Understanding the output command

Could you please explain me whats happening in the below code, appreciate your help, Thank you. /product/apps/informatica/v7/pc/ExtProc/NewDAC/ /product/apps/informatica/v7/pc/TgtFiles/NEW_DAC/DAC_Pos_TradeInv_Records.out ... (5 Replies)
Discussion started by: Ariean
5 Replies

7. Shell Programming and Scripting

understanding mv command

hi i was moving a file from one directory to another with the following cmmand mv /home/hsghh/dfd/parent/file.txt . while doing so i i accidently mv /home/hsghh/dfd/dfd . although i gave ctrl c and terminate the move command some of the file are missing in the parent directory and... (1 Reply)
Discussion started by: saravanan71184
1 Replies

8. Shell Programming and Scripting

understanding the kill command

Hi Guys, I like to know if i have a process which triggers 10 different child processes. How to identify out of the 11 processes running which is the parent process and what are the child process? And if i kill the parent process will the child process be killed.. if not is there a way to... (2 Replies)
Discussion started by: mac4rfree
2 Replies

9. Shell Programming and Scripting

Help Needed in understanding this command

Hi All, I search the forum for my query, Glad that got solution to it. But i really want to understand how does this command work. sed -e ':a' -e 's/\("*\),\(*"\)/\1~\2/;ta' Basically it is replacing all the comma(,) characters in between quotes with a tilde. Specially what does ':a' ,... (2 Replies)
Discussion started by: DSDexter
2 Replies

10. UNIX for Dummies Questions & Answers

Need Help Understanding a Unix Command

Trying to install something. Can someone explain what this means? chmod -R a+r . chmod -R a+w logo.gif tempdir/ templates_c/ I recognize that file permissions are being changed (chmod), but beyond that, it's Greek to me. (6 Replies)
Discussion started by: chris86
6 Replies
Login or Register to Ask a Question

Featured Tech Videos