All Questions
Tagged with shell-script awk
1,007 questions
0
votes
5
answers
187
views
Rename a set of files according to a specific scheme, with rename back option
In Linux in a directory there are files, ls -1 shows me this output :
file1.1-rvr
file1.2-rvr
file1.3
file1.4-rvr
file1.5
file1.6-rvr
file2.1
file2.2
file3.1
file3.10
file3.2-rvr
file3.3-rvr
file3.4
...
6
votes
3
answers
838
views
How to read a line from a file and output the line to a file
A file like this: ExampleFile.txt
line1TextHere
line2TextHere
line3TextHere
I would like to read a line one by one from the file and output it to different files, so there will be one file for each ...
4
votes
3
answers
237
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
106
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
469
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
59
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
159
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
162
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
85
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
261
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
795
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
307
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
107
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
79
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
91
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 ...