![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| reading ps command's output line by line | s. murat | Shell Programming and Scripting | 5 | 05-22-2008 05:23 AM |
| how to make a line BLINKING in output and also how to increase font size in output | mail2sant | Shell Programming and Scripting | 3 | 04-14-2008 08:30 AM |
| How to grep / zgrep to output ONLY the matching filename and line number? | vvaidyan | UNIX for Dummies Questions & Answers | 3 | 03-12-2008 05:33 PM |
| Multi-line output to single line | LinuxRacr | Shell Programming and Scripting | 7 | 02-26-2008 10:05 AM |
| Making multi line output appear on one line | djsal | Shell Programming and Scripting | 1 | 10-07-2004 07:21 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
I have a script that sorta works the way I want but I would rather
just get the base name and line number from the grep output. My current script is this one liner: grep -n "$1" $SCCSPATH/*/s.*.k | cut -c1-80 which if I was searching for 121197 I would get something like this: /versyss/data/devel/src/prsrc/2.20/vs220/s.195pr.k:2000:* fix 121197 I would rather get something like this from my grep output: s.195pr.k:2000:* fix 121197 Any ideas how this can be done (non perl answers only please) TIA Zoo591 |
|
||||
|
I tried your script RishiPahuja, but it had a problem with the basename
due to the -l option on ls as that supplied file attributes to the basename. After removing the -l option your script did work it it did not show the basename of the file beside each line#. Example of output shown below: Looking for 121197 153:* 1.32 121197 Bug fix of gross earnings update-master and prov 1922:* fix 121197 1925:* end fix 121197 2207:* fix 121197 95:* 1.32 121197 Bug fix of gross earnings update-master and prov, Thank you for trying. Zoo591 |
|
||||
|
RishiPahuja: while your answer does provide a filename it is not quite what I am
looking for as it prints the names of file even when they do not match the search pattern. Output of your script shown below: s.191pr.k : s.192pr.k : s.194pr.k : s.195pr.k : 153:* 1.32 121197 Bug fix of gross earnings update-master and prov 1 922:* fix 121197 1925:* end fix 121197 2207:* fix 121197 Becket: The sed add on you provided to my original script comes back with this error: sed: Command garbled: s|.*/||g I appreciate your help. Keep it coming. Zoo591 |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|