Search Results

Search: Posts Made By: Prathmesh
4,883
Posted By RudiC
Good grief! What a heck of a problem. We have a...
Good grief! What a heck of a problem. We have a "race condidtion" of what pattern occurs first in the pattern file and what occurs first in the string. When found a pattern, and reduced the string,...
4,883
Posted By RudiC
That's much clearer, thank you. How about (adding...
That's much clearer, thank you. How about (adding the new fields at the end, so we can print the format info as we go through the file)
awk '
FNR == 1 {FILENR++
}

FILENR...
4,883
Posted By RudiC
Hmmmm - not quite clear yet when you want the...
Hmmmm - not quite clear yet when you want the dots, and when the printf format strings, or when both... See how far this gets you:



awk '
FNR == 1 {FILENR++
}
FILENR...
4,883
Posted By RudiC
This is not easy a request, both to understand...
This is not easy a request, both to understand and to implement. I have understood that you want to search two input fields, $4 and $5, for date/Ttime format descriptors, and append their metadata to...
1,308
Posted By RudiC
Try awk -F\| ' NR==FNR {F[NR] = $1 ...
Try
awk -F\| '
NR==FNR {F[NR] = $1
MX = NR
next
}
{for (i=8; i<=NF; i++) {split ($i, T, "=")
...
1,308
Posted By rbatte1
Hello Prathmesh, Can I just confirm if this...
Hello Prathmesh,

Can I just confirm if this sorting is just to be within each record and that the output lines should be in the same order, i.e. it's horizontal sorting, so this:-
a,4,3,2,1...
3,812
Posted By RudiC
How about awk ' FNR == NR {A[NR] = $1 ...
How about awk '
FNR == NR {A[NR] = $1
B[NR] = $2 + 1
C[NR] = $2 - $3
CNT=NR
next
}
...
3,812
Posted By RavinderSingh13
Hello Prathmesh, Could you please go through...
Hello Prathmesh,

Could you please go through following and let me know if this is helpful for you.

awk 'FNR==NR{ ...
3,812
Posted By RavinderSingh13
Hello Prathmesh, A very minor change with...
Hello Prathmesh,

A very minor change with code as follows may help you in same.

awk 'FNR==NR{A[++i]=$0;next} {for(j=1;j<=i;j++){split(A[j],...
3,812
Posted By RavinderSingh13
Hello Prathmesh, Could you please try...
Hello Prathmesh,

Could you please try following and let me know if this helps you.

awk 'FNR==NR{A[++i]=$0;next} {for(j=1;j<=i;j++){split(A[j],...
2,385
Posted By RudiC
With FS="", every character is a field of its...
With FS="", every character is a field of its own. The array S holds the char positions from file2, and file1's fields (= chars) identified by S are prefixed with | .
2,385
Posted By RudiC
For awks that can handle empty field separators,...
For awks that can handle empty field separators, tryawk 'FNR == NR {S[NR] = $1; CNT = NR; next} {for (i=2; i<=CNT; i++) $S[i] = "|" $S[i]} 1' FS=, file2 FS="" OFS="" file1
12|345|sda|231453...
2,385
Posted By RavinderSingh13
Hello Prathmesh, Could you please go through...
Hello Prathmesh,

Could you please go through following and let me know if this helps you.


awk 'FNR==NR{ ####### This condition will be TRUE only when...
2,385
Posted By RavinderSingh13
Hello Prathmesh, Could you please try...
Hello Prathmesh,

Could you please try following and let me know if this helps you.

awk 'FNR==NR{A[++i]=$1;B[i]=$2;next} {for(j=1;j<=i;j++){if(B[j]){C=C?C OFS...
17,472
Posted By rbatte1
Ah, yes. I hadn't thought of Monday 7th being...
Ah, yes. I hadn't thought of Monday 7th being the first week.

Try:-((weekofmonth=1+($dayofmonth-1)/7))

Sorry about that,
Robin :o
17,472
Posted By RudiC
man bash: August and September will make the...
man bash: August and September will make the calculation fail unless the base is specified. I can't tell how far this applies to other shells...
17,472
Posted By fpmurphy
ksh93 have builtin support for such date queries ...
ksh93 have builtin support for such date queries

For example:

$ printf "%T\n" "second monday june"
Mon Jun 8 00:00:00 EDT 2015
$ printf "%T\n" "fourth monday june"
Mon Jun 22 00:00:00...
17,472
Posted By rbatte1
For my part, in the...
For my part, in the line:-((weekofmonth=1+$dayofmonth/7))... the logic is that I divide the day of the month by seven (losing any remainder) and that gives me a value between zero and four. I add...
17,472
Posted By rbatte1
Are you trying to determine if the script is...
Are you trying to determine if the script is started on the correct day, i.e. 2nd & 4th Monday only?

If so, start it every day and have a section to test the date at the top similar to this:-date...
17,472
Posted By RudiC
Looks like your shell doesn't zero pad the MONTH...
Looks like your shell doesn't zero pad the MONTH sequence as does my bash. You may want to consider the various options that your shell offers for "brace expansion". Otherwise, prepend single digit...
20,777
Posted By RudiC
A few comments may lead you in the right...
A few comments may lead you in the right direction but can't replace an in depth reading of e.g. man awk plus a lot of experimenting with samples.

Arrays don't represent files, nor do the field...
20,777
Posted By Don Cragun
Reformatting Scrutinizer's first script and...
Reformatting Scrutinizer's first script and adding comments:
awk ' # Invoke awk with this script...
NR == FNR { # If the number of lines read from all files
# (NR) is equal to the number...
20,777
Posted By Scrutinizer
Hi, try: awk 'NR==FNR{A[$2]=$1; B[$2]=$3; next}...
Hi, try:
awk 'NR==FNR{A[$2]=$1; B[$2]=$3; next} {$3=A[$1]; $4=B[$1]}1' FS=, OFS=, file2 file1
or
awk 'NR==FNR{A[$2]=$1 FS $3; next} {$3=$1 in A?A[$1]:FS}1' FS=, OFS=, file file1
1,918
Posted By sea
Quite a basic task, isnt it? (untested) ...
Quite a basic task, isnt it?

(untested)
SRC=Sample1.txt
PARSE=BW*20141112*.csv
OUT=/home/paxk1/test.csv

while read pattern;do
grep "$pattern" $PARSE >> "$OUT"
done<"$SRC"

Hope this...
2,773
Posted By Corona688
Files do not work that way, you can't insert in...
Files do not work that way, you can't insert in the middle. That's why we have text editors to do it for us.

If whatever's using this huge file can read from standard input, you can skip editing...
Showing results 1 to 25 of 33

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