Search Results

Search: Posts Made By: Amit Joshi
8,329
Posted By RudiC
This description is a bit diffuse. Tryawk -v...
This description is a bit diffuse. Tryawk -v COL=$ColumnNo -v SRCH="$PPK" -v REP="$NPK" '
{FS=OFS="\""; $0=$0 # recalculate fields based on " delimiter
...
3,523
Posted By Don Cragun
It looks like you're doing well. The script...
It looks like you're doing well.

The script sets IAm to the basename of the name of the script. The shell expands $0 to the pathname used to invoke your script. Let's assume your script is named...
3,523
Posted By Don Cragun
Perhaps something like this would be a good...
Perhaps something like this would be a good starting point:
#!/bin/ksh
IAm=${0##*/}
if [ $# -lt 2 ]
then printf '%s: Not enough operands\n' "$IAm" >&2
printf 'Usage: %s file...
12,802
Posted By bakunin
This command prints everything between a line...
This command prints everything between a line containing "BEGIN" and one containing "END", regardless of what is in between.

Your problem is, if i have understood correctly, is to only print these...
12,802
Posted By MadeInGermany
Another awk solution, that doesn't need two times...
Another awk solution, that doesn't need two times the /END/ expression:
awk '/BEGIN/ {block=1} block {str=str sep $0; sep=RS} /END/ {block=0; if (str~/Amit/) {print str} str=sep=""}' file
12,802
Posted By anbu23
$ awk ' /BEGIN/,/END/ { str = str ? str "\n" $0...
$ awk ' /BEGIN/,/END/ { str = str ? str "\n" $0 : $0 } /END/ { if( str ~ /Amit/ ) { print str }; str = "" } ' file
******** BEGIN *****
My name is Amit.
I am learning unix.
***** END *****

...
Showing results 1 to 6 of 6

 
All times are GMT -4. The time now is 08:52 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy