![]() |
|
|
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 |
| Need Replacement for sed | dbsurf | Shell Programming and Scripting | 0 | 01-25-2008 06:47 PM |
| KSH - Character Replacement | mixxamike | Shell Programming and Scripting | 2 | 09-24-2007 04:43 PM |
| Regarding Replacement | rajx | UNIX for Dummies Questions & Answers | 2 | 05-22-2007 10:19 AM |
| Replacement using sed | handak9 | UNIX for Dummies Questions & Answers | 5 | 07-13-2004 12:28 PM |
| cpu replacement. help | IMPTRUE | UNIX for Dummies Questions & Answers | 3 | 07-25-2003 09:40 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Awk replacement
Hi all, I need help in replacing awk with sed for the below. 1 ) Code:
cat list | awk -F" |," '/MATH/ {sub(/[[:alpha:]]*/,"",$3); print $3}'
Eg: file : list Sno Subno Name 1 SUB1 ENG 2 SUB2 MATH 2) Eg:result Total No of Students: 2 Sno ID Sub ------------------ 1 120 ENG 2 2 ENG 3 10 MATH Here I need no of students Code:
cat result | awk '/Total/ {print $5}'
the o/p would be : 2 other case , I need the IDs alone Code:
cat result| awk '{print $2}' | grep '[[:digit:]]' | tr '\n' ' '
The o/p would be : 120 2 10 For the above what can be the possible sed replacements ? Thanks, Priya. |
|
||||
|
one way.. Code:
-bash-3.2$ cat file Total No of Students: 2 -bash-3.2$ cut -d" " -f5 file 2 -bash-3.2$ -bash-3.2$ cat file2 Sno ID Sub ------------------ 1 120 ENG 2 2 ENG 3 10 MATH -bash-3.2$ grep [[:digit:]] file2 | cut -d" " -f2 120 2 10 -bash-3.2$ |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|