Linked Questions

4 votes
2 answers
17k views

In my bash script I have a variable that I am trying to pass to a pattern to search for using awk. However what I expected to happen is not working. I have the following text file (text.txt): --------...
pdm's user avatar
  • 65
3 votes
2 answers
12k views

How to insert bash variables in awk (for example i need to do in in some for loop - like this: in first iteration use awk to search string by first column, next by second column and so on with using ...
dmgl's user avatar
  • 1,093
0 votes
2 answers
11k views

I have a script like this #!/bin/ksh echo "Enter the matching pattern" read pattern path= /home/siva/ echo "Navigating to $path" cd $path cat filename|awk '/$pattern/ {for (i=1; i<=10; i++) {...
Siva's user avatar
  • 9
1 vote
1 answer
6k views

With an array of elements, and an input-file I want to loop through the array and match each element with the input-file. I then want to get the line in the input-file where this element is occurring ...
sku2003's user avatar
  • 177
2 votes
1 answer
1k views

I would like to know how to pass a argument to a Bash function which would consequently serve as a pattern to awk. I have read several Q/As which tend to answer the same question, however, I am ...
menteith's user avatar
  • 292
-1 votes
1 answer
1k views

How to use a value of a variable in awk? Something like this: filename = "test.txt" ls -l | awk '{ if ($9 == filename) print("File exists")}' I can't use $ in awk to access the value of that ...
ABC's user avatar
  • 229
1 vote
1 answer
952 views

I realize this has been asked many times and many of the answers seam well written, but I'm missing something with my little task. Trying to pass a Shell variable (an argument in this case) to awk to ...
user47812's user avatar
0 votes
2 answers
1k views

I am making a word list from all the words typed into a program that will be working with the text entered into it. I want to use a stream editor like sed or awk to search the first word of every ...
XBuilder's user avatar
3 votes
1 answer
246 views

I have the following AWK command which works well. awk -v RS="\n+?[$]{4}\n+?" '/HMDB0000008/' test.xt However what I want is to be able to call it from the command line and pass an argument ...
js352's user avatar
  • 133
1 vote
2 answers
1k views

I'm trying to match a pattern and then print out two lines after it. I'm successfully able to do it with the following code. awk '/'202404'/{c=3}c&&c--' consolelog.log > testing.txt I'm ...
Vineeth Thomas's user avatar
0 votes
1 answer
260 views

I am trying to extract context from a file with awk from a start pattern until an end pattern. Here is simplified sample input to reproduce: $ cat file 1 2 3 4 5 6 When I pass the start pattern ...
Zlemini 's user avatar
1 vote
1 answer
529 views

we have the following file cat /tmp/hive.conf "hive-exec-log4j2" : { "tag" : "TOPOLOGY_RESOLVED", "version" : 2 }, "hive-interactive-env" : { "tag" : "...
yael's user avatar
  • 14k
-1 votes
1 answer
182 views

So I have my targets array which is a bunch of IP read from a file, now I am trying to cat a file that contains my IP and results from ssh command, ut because I am trying 3 different passwords on ...
dwt.bar's user avatar
  • 145
0 votes
1 answer
198 views

I have the below variables: grep_line_new_file='create table "informix".issue' new_file_below=`awk 'BEGIN { FS="\n[()]"; RS=";" } /$grep_line_new_file/ { print ")"$NF";"}' test` Inside test file I ...
Christopher Karsten's user avatar
1 vote
1 answer
60 views

#!/bin/bash awk 'NR!~/^(1|$q+2|$q+3)$/' deltay.txt > yota.txt q is an integer obtain from a previous process in the script, and I need to erase lines one, the q+2 an q+3, but that command just ...
Diego's user avatar
  • 319

15 30 50 per page