All Questions
Tagged with shell-script awk
1,005 questions
4
votes
3
answers
220
views
Add columns from variable number of files to base file
I'm dealing with a series of bed files, which look like this:
chr1 100 110 0.5
chr1 150 175 0.2
chr1 200 300 1.5
With the columns being chromosome, start, end, score. I have multiple different files ...
2
votes
3
answers
86
views
Printing a specific section everytime search results are matched
I have a pretty basic text file on a Linux machine that has stuff like Chapters, Dialogues and References.
This is what it looks like
Chapter: 1 One: Birds and Trees
Birds are beautiful and trees ...
2
votes
3
answers
434
views
Replace prefix string from lines in a file, and put into a bash array
In the file groupAfiles.txt are the lines:
file14
file2
file4
file9
I need a way to convert them to remove file and add /dev/loop and put them all in one line with a space between them.
/dev/loop14 /...
0
votes
1
answer
43
views
Format output and columms
In Linux in Bash in a for loop i do:
... ; do echo "$i --> $i-new" ; ...
The output is than something like this:
file1 --> file1-new
file2 --> file2-new
...
file9 --> ...
1
vote
0
answers
123
views
get unique lines from a file [closed]
For reference, this is a follow-up on @EdMorton's answer to my previous question: make master/slave ip in different subnet
I have a file have duplicates on both first column and the second column,just ...
1
vote
3
answers
133
views
make master/slave ip in different subnet
For reference, this is a follow-up and variation on group ip address to different subnet with shell
We have two strings (named master/slave), the two strings are composed with IPS spread in three ...
-3
votes
2
answers
77
views
grep specified variable from a file [closed]
I have a variable like
master='172.21.154.37 172.21.250.94 172.21.251.93 172.21.250.94'
and I need to check whether the first and the second column in the file both matches the variable. The following ...
1
vote
4
answers
234
views
swap matched columns
I have an awk issue need your help,I just need to grep on the second column and if matched,swap the second column with the first column.
172.21.154.40 172.21.254.25
172.21.250.94 172.21.154.37
172.21....
1
vote
6
answers
668
views
Bash script that takes multiple path arguments and checks if files can be successfully created there
I would like a bash shell script (for my Debian 12 system) which accepts multiple paths as arguments, and then checks if a file can be successfully created in each one. Then the result should be put ...
3
votes
2
answers
291
views
shell script to match a function in a file and replace it with another function in another file
I have files that contains multiple functions like below.
file1.c:
static void function1()
{
code
}
...
static void functionX()
{
code
}
...
static void lastFunction()
{
code
}
file2.c:
...
-3
votes
2
answers
100
views
Using awk, append a value in last field in csv file based upon value in specific field
input.csv -
"family_guy","Brian","b47f0a80-d848-4d81-a45b-7ba930e6048b","son"
"family_guy","Brian","b47f0a80-d848-4d81-a45b-...
-2
votes
1
answer
67
views
regular single column data to multiple rows
source data
KKK-SNMImsi: 444444
KKK-SNMUserProfileId: KKK-SNMDefaultAutomaticProfile
KKK-SNMMmeAddress: TDSGSN01
KKK-SNMMsisdn: 44235682436
KKK-SNMLocationState: LOCATED
KKK-SNMRoamingAllowed: FALSE
...
0
votes
2
answers
81
views
extract a column from the command output even if it blank bash
I am trying to extract 2nd column from a command output
For example:
$ sudo /usr/sbin/pvs
PV VG Fmt Attr PSize PFree
/dev/sdc1 vgswap lvm2 a-- 16.00g 0
/dev/sdc2 ...
-1
votes
5
answers
301
views
Delete all lines after n lines below the line containing the first match
If a file contains the following:
Line 1
FooLine 5
Line 2
Line 55
Line 3
Line 4
Line 5
Line 6
Line 7
Line 5
Line 8
Line 9
How to delete the lines below two lines after "Line 5", so that the ...
4
votes
3
answers
552
views
Two ssh output as awk input
I have two remote servers that I am trying to ssh and cat some files.. I want to input the output of the ssh to a awk command.
This is what I have got
ssh username@host1 “cat /tmp/test/*” ssh ...