Reputation: 99
My output looks like below
judi# *diff -C 0 $* mountYday mountTday
*** mountYday Sat Jun 13 02:57:09 2015
--- mountTday Sat Jun 13 02:59:49 2015
***************
*** 20 ****
- /test on /dev/vx/dsk/test/test read/write/setuid/devices/intr/largefiles/logging/xattr/onerror=panic/dev=48986a5 on Wed Apr 22 22:28:04 2015
--- 19 ----
judi#
I need to get only the line starts with single "-". The output should be as
- /test on /dev/vx/dsk/test/test read/write/setuid/devices/intr/largefiles/logging/xattr/onerror=panic/dev=48986a5 on Wed Apr 22 22:28:04 2015
I am able to eliminate the first two lines using awk:
*# diff -C 0 $* mountYday mountTday | awk '! /mount/'*
***************
*** 20 ****
- /ora03/oradata1 on /dev/vx/dsk/GRPA056L/ora03-oradata1 read/write/setuid/devices/intr/largefiles/logging/xattr/onerror=panic/dev=48986a5 on Wed Apr 22 22:28:04 2015
--- 19 ----
How do I remove the lines starts with ***
and ---
(exactly 3 ***
and ---
) and the ***************
(15 Characters)? I am trying with awk in single command.
Upvotes: 1
Views: 59
Reputation: 5223
Instead of removing characters you don't want, how about a command to find the character you do want? The line you want is "start of line, followed by a single -, followed by space".
$ diff -C 0 $* mountYday mountTday | awk /- / {print $0}
This sort of pattern extraction is more suited to grep:
$ diff -C 0 $* mountYday mountTday | grep '^- '
Upvotes: 2