Unix scripting doubts


 
Thread Tools Search this Thread
Operating Systems Solaris Unix scripting doubts
# 15  
Old 05-10-2010
There are simpler ways:

Code:
ls tpa* >/dev/null 2>&1 || echo "No jobs available which starts with tpa*"

or

Code:
if [ ! -e tpa* ] ; then echo "No jobs available which starts with tpa*" ; fi

# 16  
Old 05-11-2010
hi Jlliagre, the for loop is giving good results for the files in above format, but for the files like below:
-rwxr-xr-x 1 oprvdw svemietl 4771 Mar 9 2009 vrc002093j.ksh
-rwxr-xr-x 1 oprvdw svemietl 4773 Mar 9 2009 vrc002092j.ksh
-rwxr-xr-x 1 oprvrc controlm 5428 Apr 3 2009 vrc045016j.ksh
-rwxr-xr-x 1 oprvrc controlm 5354 Apr 3 2009 vrc055141j.ksh
-rwxr-xr-x 1 svemietl controlm 2745 Feb 16 02:20 bdw0231185.sh
-rwxr-xr-x 1 svemietl controlm 2672 Feb 16 02:20 bdw0231145.sh

it displaying o/p as
oprvdw :
vrc002093j.ksh
vrc002092j.ksh
oprvrc :
vrc045016j.ksh
vrc055141j.ksh
svemietl :
vrc002093j.ksh
vrc002092j.ksh
bdw0231185.sh
bdw0231145.sh

So plz suggest me how to change this for loop to print as below:
oprvdw :
vrc002093j.ksh
vrc002092j.ksh
oprvrc :
vrc045016j.ksh
vrc055141j.ksh
svemietl :
bdw0231185.sh
bdw0231145.sh
# 17  
Old 05-11-2010
Quote:
Originally Posted by p_satyambabu
So plz suggest me how to change this for loop to print as below:
Maybe adjusting this line:
Code:
  grep " $i " file | awk '{print $9}'

to
Code:
  grep "1 $i " file | awk '{print $9}'

will work.
# 18  
Old 05-11-2010
Hi, i tried by putting 1 in front of $1 but its not working ,
# 19  
Old 05-11-2010
It should go in front of $i !
Code:
for i in $(awk '{print $3}' file | uniq)
do
  echo $i:
  grep "1 $i " file | awk '{print $9}'
done

If it doesn't work, you'll have to wait for jlliagre
# 20  
Old 05-11-2010
sorry, its working fine, thanku.
can u plz explain what will happen if we put 1 infront of $i?
# 21  
Old 05-11-2010
Quote:
Originally Posted by p_satyambabu
can u plz explain what will happen if we put 1 infront of $i?
Sure. Until now, the for loop searched for username everywhere in the file, including the group column.
But after your latest modification, it will only search for username in the username column (column next to the column with the ones).

-rwxr-xr-x 1 oprvdw svemietl 4771 Mar 9 2009 vrc002093j.ksh
-rwxr-xr-x 1 oprvdw svemietl 4773 Mar 9 2009 vrc002092j.ksh
-rwxr-xr-x 1 oprvrc controlm 5428 Apr 3 2009 vrc045016j.ksh
-rwxr-xr-x 1 oprvrc controlm 5354 Apr 3 2009 vrc055141j.ksh
-rwxr-xr-x 1 svemietl controlm 2745 Feb 16 02:20 bdw0231185.sh
-rwxr-xr-x 1 svemietl controlm 2672 Feb 16 02:20 bdw0231145.sh

Hope I was comprehensible.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Few doubts on Linux scripting

1) I have to create 3 scripts which create different output files. Script one creates datafiles, script2 creates control files and script3 creates flg files. The business wants the same timestamp to be attached to all the files created by these scripts. Script1- Create data files - Data files... (2 Replies)
Discussion started by: Maya_Pillai
2 Replies

2. Shell Programming and Scripting

shell scripting doubts

Hello All, I am working in a reputed software firm,currently working on testing platform (manual and automation).But I am very much intersted in unix and shell scripting,I feel that I am good at beginner level of shell scripting,still I want to practise shell scripting to become excel in it.I... (1 Reply)
Discussion started by: maheshglm
1 Replies

3. UNIX for Dummies Questions & Answers

Unix doubts

Hi All, 1. how and who calls .profile when you login 2. what is PPID and what means by PPID = 0 Thanks in Advance (2 Replies)
Discussion started by: ravi.sadani19
2 Replies

4. UNIX for Dummies Questions & Answers

Basic doubts related to Unix

Hi all, I have few question related to Unix environment and commands : 1. what is .chrc file contain and if it is not present then what happens. 2. what is .login file contain,in which dir it is present and what all other uses are their for this file 3. how and who calls .profile when you... (2 Replies)
Discussion started by: ravi.sadani19
2 Replies

5. UNIX for Dummies Questions & Answers

unix doubts

Write unix command to list or view auto links (0 Replies)
Discussion started by: ashishshah.engg
0 Replies

6. Forum Support Area for Unregistered Users & Account Problems

How to post a new thread (Regarding Unix related doubts) in Unix Forums

How to post a new thread (Regarding Unix related doubts) in Unix Forums. I registered my id but I am unable to post my Questions to Forum. Thanks & Regards, indusri (1 Reply)
Discussion started by: indusri
1 Replies

7. UNIX for Dummies Questions & Answers

Unix doubts

Hello All, I am very new to UNIX. Please help me to find answers of below questions. 1.A script is saved with name ls. When we execute the script what it will execute? a) Will execute ls command b) Will execute the script c) Will execute script or command depends on the path ... (2 Replies)
Discussion started by: aswathy
2 Replies

8. Programming

Doubts About C Compiler In Unix/linux

As all of you know whenever a program "say a.c" is complied in linux using the gcc or the cc compiler..it shows the list of errors ( if the program contains any).. i want to modify the compier script so as to list the no of errors only and not the description about the error..like" parse error " ... (1 Reply)
Discussion started by: vrs
1 Replies

9. Solaris

Unix Administration doubts ********

Hi, Can anyone tell me the correct answers for these: 1. You have 4 instances running on the same UNIX box. How can you determine which shared memory and semaphores are associated with which instance? 2. How do you increase the OS limitation for open files (LINUX and/or Solaris)? Thanks:p (1 Reply)
Discussion started by: dreams5617
1 Replies

10. UNIX for Advanced & Expert Users

unix & C doubts

Hi, I have a few doubt here : 1) I want to run a 3 different 'C' programs in same session simulteneously (parelelly). if I make a shell, it is running one after another, I mean it shout run in 3 processors. 2) In 'C' program, how can I assing a value of the unix commant cat a.txt|wc... (1 Reply)
Discussion started by: krishna
1 Replies
Login or Register to Ask a Question