33,202 questions
-1
votes
1
answer
99
views
Using awk in ksh script
I have a requirement to split a large CSV file using KSH script. I came across below link which is using AWK utility
Split CSV files into smaller files but keeping the headers?
I tried the same as ...
0
votes
3
answers
98
views
extract rows when column value greater than specified and also incremented at least five times [closed]
With the following input,
08 V 3.8 0.0 23.456 60.459 60.459
09 M 4.4 0.0 24.960 72.301 72.301
10 L 4.4 0.0 25.301 95.197 95.197
11 L 1.9 0.0 25.410 ...
4
votes
4
answers
89
views
Awk matching patterns and removing adjacent lines
I've got the volumetric data from different brain regions and I'm trying to sort it out to make the analysis easier. To get an idea this is a part of what I've got:
LT_Putamen 5075 5075.000000
...
-1
votes
1
answer
72
views
getline advances to next file instead of returning EOF
getline is specified to read "from the current input file" and to return 0 at the end-of-file. Both gawk and POSIX docs use this verbiage. It makes sense: Data may be divided between files ...
2
votes
2
answers
68
views
Compare every other column in a file to one column in another file (including non matching records)
I have file1.gz That looks like
NC_044998.1 4013 0 TT 2 GG 0 TT 0 TT 0 TT
NC_044998.1 4016 0 TT 0 TT 0 ...
-1
votes
1
answer
87
views
How to update JSON file in shell script without using jq?
I am using shell script to update JSON. Previously I used jq command to read/write an JSON object. However it seems not every bash environment support jq command. I tried to resolve this issue by ...
3
votes
3
answers
82
views
Print lines between patterns with awk
Going back to this discussion:
Print all lines between two patterns, exclusive, first instance only (in sed, AWK or Perl)
The proposed solution fails once the ending pattern is a substring of the ...
2
votes
1
answer
48
views
What is the meaning of array index [fp+0] in awk example?
At this page https://www.gnu.org/software/gawk/manual/html_node/More-CSV.html, have this example to work on awk with csv files.
The example works very well!
But, I couldn't understand the fpat+0 on ...
-2
votes
1
answer
64
views
What's new in POSIX Awk 2024? [closed]
A while ago I stumbled upon the POSIX 2024 (issue 8) specification, and today I'm trying to figure out the differences between Awk 2018 (issue 7) and Awk 2024 (issue 8).
For eg. I found out that ...
-1
votes
0
answers
31
views
Linux awk transliterate column base [closed]
I have below data to be translated
C1|C2
ABCD|EFGH
EFGH|ABCD
I want to transliterate only the specific colour, let's say C2.
I tried this but
awk -F'|' -v OFS='|' -vcol=C2 'NR==1 {for(i=1;i<NF;i++)...
4
votes
6
answers
106
views
While using AWK, I'd like to verify that the NF is >= 10. If not, write the line to a reject file
I have an AWK script that is embedded in BASH code.
cat MyFile.csv | awk -v reject_file=MyRejectFile.csv "${AWK_SCRIPT}" | <generic loader>
And here is my AWK_SCRIPT...
AWK_SCRIPT='...
0
votes
1
answer
65
views
Using Variables Within & Outside awk
I am trying to use awk to detect System.debug statements in .cls files from pull requests, excluding those found within try/catch blocks using:
awk '
BEGIN {
IGNORECASE = 1
}
/try\s*{/ {
...
3
votes
5
answers
139
views
How can you use awk to replace a pattern with an environment variable?
I am trying to write a simple script that will receive a text via standard input and will output everything as it is except it will replace occurences following this pattern:
{{env MYVAR}}
{{env PATH}...
-4
votes
5
answers
90
views
How do I replace a character and add another one in front of a line one line below of it? [closed]
My goal is to overwrite the / character with a - at the end of a particular line and then insert a - at the front of that line and also at the front of the line one line below it. The test I've done ...
0
votes
2
answers
124
views
What is the effect of the “IGNORECASE” flag on how the “gensub” function works with multi-byte characters? [closed]
I have the 6-byte text file (input.txt). It contains one line of three characters:
αβγ
The file is in UTF-8. It can be generated by the following command:
echo 'CEB1CEB2CEB3' | xxd -r -p > input....