Search Results

Search: Posts Made By: pchang
5,528
Posted By vgersh99
awk -F"," 'FNR==1{next}; ....'
awk -F"," 'FNR==1{next}; ....'
5,984
Posted By nezabudka
Hi, @RudiC awk ' NR==FNR {pat[$1] = $2 ...
Hi, @RudiC
awk '
NR==FNR {pat[$1] = $2
next
}
{print substr($0, 134, 12)
}
' FS='|' File2.txt File1.txt | cat -vet

606951-000 $
606951-000 $
607650-000 ...
5,984
Posted By RudiC
The OP specified , that's what the formatted...
The OP specified , that's what the formatted sprintf is for. As the sample data are just 10 byte long, not 12, we need to wait until resolved by the OP, we can just guess. Try this simplified but...
1,581
Posted By RudiC
In awk, the substr() function is used to extract...
In awk, the substr() function is used to extract (partial) strings, but can't be assigned to. You'd need to either break up the line, with substr()s, and reassemble with the new data, or use the...
5,517
Posted By vgersh99
a slight mod: awk ' /<accountHolderName/...
a slight mod:

awk '
/<accountHolderName/ {accH=FNR}
FNR==NR {
if (/<AdditionalAccountHolders/) {s[accH]=$0;f++;next}
if (f) s[accH]= s[accH] ORS $0
if...
5,517
Posted By vgersh99
well... your original sample data contained only...
well... your original sample data contained only ONE holder record - not 2 as in the new sample.
You should be more descriptive in the future...
Let me rework the suggestion with the NEW sample.
10,768
Posted By Scrutinizer
Hi, try: awk '{sub(/[ ,]+$/,"",$1); print}'...
Hi, try:
awk '{sub(/[ ,]+$/,"",$1); print}' FS='\t' OFS='\t'

or

awk '{sub(/[ ,]+\t/,"\t"); print}'
2,174
Posted By RudiC
Please get accustomed to reading man awk! ...
Please get accustomed to reading man awk!

awk works on pattern {action} pairs for every input record: execute action if pattern is TRUE.

awk '
rec_type1=substr($0,13,4) #...
2,174
Posted By RudiC
How about awk '/AM00/ {SUFFIX = $NF} /AM01/...
How about

awk '/AM00/ {SUFFIX = $NF} /AM01/ {CARD = $NF; $0 = $0 FS SUFFIX} /AM32/ {$0 = $0 FS SUFFIX FS CARD} 1' FS=, file3
AM00,1,12345
AM01,ab,677,12345
AM32,10,12345,677
...
2,174
Posted By vgersh99
awk -F, '$1=="AM00" {n=$NF;print;next} NF &&...
awk -F, '$1=="AM00" {n=$NF;print;next} NF && !/--/ {$(NF+1)=n}1' OFS=, myFile
9,140
Posted By vgersh99
BEGIN { split(token_search_string, a, "|") ...
BEGIN {
split(token_search_string, a, "|")
}
{
{
s=t=$0
for(i=1;i in a; i++) {
t=s
while (match(t, a[i])) {
print substr(t, RSTART, token_search_length)
...
9,140
Posted By Aia
In the shell token_search_string='536088|547698'
In the shell
token_search_string='536088|547698'
1,284
Posted By Don Cragun
You need a -v option for each variable you're...
You need a -v option for each variable you're setting; not just the first one.

If there is any chance that string_to_search could contain any whitespace characters or characters that have special...
6,447
Posted By RudiC
Try awk '!$6{$6=0}1' FS="|" OFS="|"...
Try awk '!$6{$6=0}1' FS="|" OFS="|" file
9,528
Posted By verdepollo
sed 's|/\([0-9][0-9]*\)|FW_SLASH\1|g' infile
sed 's|/\([0-9][0-9]*\)|FW_SLASH\1|g' infile
5,157
Posted By Don Cragun
I'm not sure if this is general enough for your...
I'm not sure if this is general enough for your real input, but the following awk script works for your input sample:
awk -v sq="'" '
copy { print
next
}
found && $2 == "AS" {
...
1,139
Posted By Corona688
Whoops, typo. ls -tp abc* | grep -v "/$" |...
Whoops, typo.

ls -tp abc* | grep -v "/$" | awk -v MAX="$1" 'NR > MAX' | xargs echo rm
1,050
Posted By Scrutinizer
Try: awk -F\| '$6+0>0' file
Try:
awk -F\| '$6+0>0' file
15,727
Posted By Klashxx
Try this (and donīt forget the code tags in your...
Try this (and donīt forget the code tags in your posts):
awk -F\| 'NR==FNR{a[$1]++;next}a[$1]' file1 file2
5,834
Posted By shamrock
And here's the awk version... awk -F\| '{ ...
And here's the awk version...

awk -F\| '{
n=split($2,a,"-")
for (i=n; i; i--) {
if (a[i]=="Jan") a[i]="01"
else if (a[i]=="Feb") a[i]="02"
else if...
1,167
Posted By Shell_Life
#!/usr/bin/ksh mValue=$(cat File2) sed...
#!/usr/bin/ksh
mValue=$(cat File2)
sed "s/var_hostname/${mValue}/" File1
2,148
Posted By vgersh99
sed "s#'[^'][^']*#'newdate#1" myFile replace...
sed "s#'[^'][^']*#'newdate#1" myFile

replace
match pattern: single-quote followed by anything BUT a single-quote repeated 1 or more time
with
single-quote followed by a string newdate

1 -...
1,740
Posted By Corona688
BEGIN { ...
BEGIN {
mon="JAN|FEB|MAR|APR|MAY|JUN|JUL|AUG|SEP|OCT|NOV|DEC"
# Create an array where mon[1]=JAN, mon[2]=FEB, etc.
monN=split(mon, monA, "|");
}
{
# NF is the number of fields, $NF...
1,740
Posted By vgersh99
nawk -F'|' -f pc.awk OFS='|' myFile pv.awk: ...
nawk -F'|' -f pc.awk OFS='|' myFile

pv.awk:

BEGIN {
mon="JAN|FEB|MAR|APR|MAY|JUN|JUL|AUG|SEP|OCT|NOV|DEC"
monN=split(mon, monA, "|");
}
{
n=split($NF,a,"[/ ]")
...
2,186
Posted By Franklin52
sed 's/\(sysdate-[0-9]*\)/&000/' file
sed 's/\(sysdate-[0-9]*\)/&000/' file
Showing results 1 to 25 of 26

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