awk Questions
3
Solved
The section 3.4 Using Bracket Expressions of GNU awk manual, reads
To include one of the characters ‘\’, ‘]’, ‘-’, or ‘^’ in a bracket expression, put a ‘\’ in front of it. For example:  ...
Foreigner asked 2/11 at 14:38
4
Solved
I need to change the order of a string in AIX, but with the command cut I can't do it
Ex:
echo FT0215202301.xml | cut -b 7-10,5-6,3-4
Result:
02152023
Expected:
20230215
3
Solved
I'm trying to add a column (with the content '0') to the middle of a pre-existing tab-delimited text file. I imagine sed or awk will do what I want. I've seen various solutions online that do appro...
4
Solved
7
Solved
I have a file with an identifier and a value:
ABC123 111111
ABC123 111111
ABCDEF 333333
ABCDEF 111111
CCCCCC 333333
ABC123 222222
DEF123 444444
DEF123 444444
Both columns contain duplicate values,...
5
Solved
here is column 6 in a file:
ttttttttttt
tttttttttt
ttttttttt
tttttttattt
tttttttttt
ttttttttttt
how can I use awk to print out lines that include "a"
6
Solved
I have a valid YAML:
---
name: first
metadata: a
---
name: second
metadata: b
---
name: third
metadata: c
How can I split it using a one-liner AWK script in files first.yaml, second.yaml and thi...
1
Solved
This it taken from the "awk-exercises".
For the input file patterns.txt, filter lines containing three or more
occurrences of "ar" and replace the last but second "ar"...
8
Solved
I have pattern like below
hi
hello
hallo
greetings
salutations
no more hello for you
I am trying to replace all newlines with tab using the following command
sed -e "s_/\n_/\t_g"
but it's not...
8
awk -F: '{ printf "%-3s %-2s","\n" $1 $2; }'
How do i add in color code? '\e[1;32m'
I try adding in to printf, it give me output of the string instead of color code..
'\e[1;32m' .......
6
Solved
I want to select line of a file where the absolute value of column 9 is less than 500. Column is sometimes positive, sometimes negative.
awk -F'\t' '{ if ($9 < |500|) {print $0} }' > output....
7
Solved
I'm streaming data using netcat and piping the output to gawk. Here is an example byte sequence that gawk will receive:
=AAAA;=BBBB;;CCCC==DDDD;
The data includes nearly any arbitrary characters, ...
5
Solved
I have nearly 200 files and I want to find lines that are common to all 200 files,the lines are like this:
HISEQ1:105:C0A57ACXX:2:1101:10000:105587/1
HISEQ1:105:C0A57ACXX:2:1101:10000:105587/2
HIS...
7
Solved
I have three types of strings that I'd like to capitalize in a bash script. I figured sed/awk would be my best bet, but I'm not sure. What's the best way given the following requirements?
single ...
8
Solved
I want to print lines from their beginning to selected characters.
Example:
a/b/i/c/f/d
a/e/b/f/r/c
a/f/d/g
a/n/m/o
a/o/p/d/l
a/b/c/d/e
a/c/e/v
a/d/l/k/f
a/e/f/c
a/n/d/c
Command:
./hhh.c...
Gielgud asked 14/6 at 6:15
5
Solved
Is it possible to have an awk command within a bash script return values to a bash variable, i.e.,if my awk script does some arithmetic operations, can I store the answers in variables so, they can...
4
Solved
I would like to extract sequences from the multifasta file that match the IDs given by separate list of IDs.
FASTA file seq.fasta:
>7P58X:01332:11636
TTCAGCAAGCCGAGTCCTGCGTCGTTACTTCGCTT
CAAGTC...
Kalin asked 9/4, 2018 at 11:1
0
I am trying to create a gawk extension that adds the ability to register signal handlers for specific signals in gawk which currently there is no built in way to do. After reading the gawk document...
2
Solved
I'm running an awk script on a 100G+ file. I have a suspicion that since it never finishes it got into some kind of infinite loop.
I want to see the line that script is currently at to see if there...
4
Solved
I want to divide two numbers in awk, using integer division, i.e truncating the result. For example
k = 3 / 2
print k
should print 1
According to the manual,
Division; because all numbers ...
2
I would like to encapsulate a user-provided ERE in parenthesis while retaining its original meaning when I use it with awk's match, split, sub, etc... If you wonder why I want to do that then you c...
4
Solved
I'm trying to implement an awk function for splitting a string into an array; the fundamental difference with the built-in split is that one is able to limit the number of "splits" that a...
6
Solved
Let's say that you have a file which contains N whitespace-delimited columns and an additional column which has spaces in it that you want to keep.
Example with N = 2:
1.1 1.2 data for row1
2.1 2....
8
Solved
I want to input a string name (i.e. "COL2") to an awk or cut command and print the column that matches that column header string.
the datafile looks like this:
COL1 COL2 COL3 COL4 COL5 CO...
Abednego asked 1/5, 2011 at 3:49
3
Solved
I am beginner to awk.
I have created one file which contains employee information.
There are employees in different departments. And i wanna count that how many employees in each department.
like
...
1 Next >
© 2022 - 2024 — McMap. All rights reserved.