[Solved] Issue with grep


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting [Solved] Issue with grep
# 1  
Old 02-07-2014
[Solved] Issue with grep

Hi everyone
I am trying to write a script to check if file systems are mounted, and also validate the permission; then do a whole bunch of other things. I am facing a problem with grep. For example, if the mountpoints are:

Code:
 
/dev/XYZ_lv      /abc/XYZ      jfs2   Nov 25 20:36 rw,log=/dev/loglv04
/dev/XYZtrace_lv /abc/XYZ/folder1 jfs2   Nov 25 20:36 rw,log=/dev/loglv04
/dev/XYZdata3_lv /abc/XYZ/folder2 jfs2   Nov 25 20:36 rw,log=/dev/loglv04
/dev/XYZdata2_lv /abc/XYZ/folder3 jfs2   Nov 25 20:36 rw,log=/dev/loglv04

If I use:
Code:
 
mount | grep -x "/abc/XYZ"

I get the whole list, not only the first line. I also tried sed, but no success.
# 2  
Old 02-07-2014
Code:
mount | grep '/abc/XYZ '

# 3  
Old 02-07-2014
Try:
Code:
mount | grep "/abc/XYZ[^/]"

# 4  
Old 02-07-2014
Exact string search in field 2
Code:
awk '$2=="/abc/XYZ"'

# 5  
Old 02-10-2014
Thanks a lot everyone; both solutions from in2nix4life and bartus11 worked for me.
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

[Solved] Issue with using for loop as for in {2..6} in korn shell

Hi i have to cut columns 2 to 6 from a file and assign it to arrays , The following code works for ctcol in 2 3 4 5 6; do set -A a$ctcol $(cut -d, -f $ctcol test_file) done how ever this does not work for ctcol in {2..6}; do set -A a$ctcol $(cut -d, -f $ctcol test_file)... (4 Replies)
Discussion started by: 100bees
4 Replies

2. UNIX for Dummies Questions & Answers

[Solved] Tail command issue in Linux

Hello, When I am trying to use tail +13 filename.csv it is throwing an error. tail: cannot open `+13' for reading: No such file or directory and then prints last 10 lines of the file. (File is present on the path) But when i try tail -13 filename.csv it runs perfectly. Could I have... (5 Replies)
Discussion started by: AnkitSenghani
5 Replies

3. HP-UX

[SOLVED] Telnet timeout issue

I have telnet configured in /etc/inetd.conf as below: telnet stream tcp6 nowait root /usr/lbin/telnetd telnetd -b /etc/issue -n20 When i restart the service telnetd shows with only the -b option: ps -ef|grep telnetd|grep -v grep root 24397 1 0 10:42:35 pts/ta 0:00... (1 Reply)
Discussion started by: Tommyk
1 Replies

4. Solaris

[SOLVED] Issue with hostname command

Hi, i'm having issues with one of my db servers, each time i run the hostname command i get "-a" as result this is the only zone on this server where i have this issue. could any one help me with this issue (5 Replies)
Discussion started by: EduardoDiaz
5 Replies

5. HP-UX

[Solved] mailx : unknown user issue

Hi all, I know this issues has been discussed multiple times, i have gone through many such discussion but unfortunately i am still not able to solve the issue being faced. I have configured the sendmail.cf with the smtp host name (Editing the entry starting with DS...) Post that restarted... (7 Replies)
Discussion started by: chpsam
7 Replies

6. Shell Programming and Scripting

[Solved] looping script issue

Hi all.. Need your help I want to combine 2 file into 1file File1 : A B C D File2 : 1 2 3 4 Result : A1 A2 A3 A4 B1 (3 Replies)
Discussion started by: buncit8
3 Replies

7. HP-UX

[Solved] Help with intermittent ping issue

We recently stood up a new server running HP-UX 11.31. Every time we do a restart we lose connectivity to the server. Can't ping in or out. I did some troubleshooting and the problem gets resolved temporarily(can ping in and out and putty to it) when we disconnect the network cable and reconnect... (4 Replies)
Discussion started by: DtbCollumb
4 Replies

8. Solaris

[solved] Jumpstart Profile Issue

I have created profile file for zfs root (flash) on a wanboot server when i try to validate the rules file with check i get following error .. i 'm not sure why i 'm getting this error .. can any one help me on this ? # ./check Validating rules... Validating profile profile... Error in... (0 Replies)
Discussion started by: fugitive
0 Replies

9. HP-UX

[Solved] File permissions issue

Hi everybody, following is the scenario; OS HP UX 11.23 two users: # id bodi uid=109(bodi) gid=20(users) groups=1(other),2(bin),3(sys),106(oinstall) # id ossmed uid=121(ossmed) gid=20(users) umask 077 directory name /home/mydir directory permissions drwxrwxrwx requirement: to... (3 Replies)
Discussion started by: ajays
3 Replies
Login or Register to Ask a Question