![]() |
|
|
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 |
| How do I read mail in /var/spool/mail? | mojoman | UNIX for Dummies Questions & Answers | 3 | 12-05-2008 04:48 PM |
| How do I read/find/replace fields in a csv datafile? | MrCarter | UNIX for Dummies Questions & Answers | 9 | 06-20-2008 11:15 AM |
| How to read and compare multiple fields in a column at the same time | ahjiefreak | Shell Programming and Scripting | 1 | 06-19-2008 12:08 PM |
| script to read from mail | misenkiser | Shell Programming and Scripting | 0 | 10-03-2006 09:07 AM |
| To Read a text file using shell Programming | sandytul | UNIX for Dummies Questions & Answers | 1 | 04-11-2001 12:15 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
KSH Programming to read and mail fields
I have a file with the following values:
File name à a.log (bulk file with 100+ lines with the similar format) aaaa|bbbb|cccc|dddd|eeee|ffff|gggg|hhhh|iiii| aaaa|bbbb|cccc|dddd|eeee|ffff|gggg|hhhh|iiii| aaaa|bbbb|cccc|dddd|eeee|ffff|gggg|hhhh|iiii| aaaa|bbbb|cccc|dddd|eeee|ffff|gggg|hhhh|iiii| aaaa|bbbb|cccc|dddd|eeee|ffff|gggg|hhhh|iiii| aaaa|bbbb|cccc|dddd|eeee|ffff|gggg|hhhh|iiii| My ksh script should do the following: 1. Open the file 2. Read the file and grep ‘gggg’ field from the last 2 lines 3. Send it to a maillist Please let me know the basic syntax of how to do this. |
|
||||
|
get the count of the file
count=`wc -l filename | cut -d " " -f1` awk -F "|" -v rec=$count 'NR>=rec{print $7}' filename | mailx -s "subject" abc.com is this what u r looking for? cheers, Devaraj Takhellambam |
|
||||
|
some code snips
I ll give some code snips
it may help u #!/bin/sh var=`tail -2 file` for i in $var; do echo $i | cut -d "|" -f7|mailx -s "subject" abc.com done Or after CUT command u need to store that value to variable and use it accordingly |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|