All Questions
Tagged with shell-script sed
855 questions
-2
votes
2
answers
123
views
Counting unique IP addresses per hour in existing log files
I am trying to determine the number of unique web visitors to my website each hour. The log files (access*.log) contain many lines looking similar to this.
192.168.211.85 - - [29/Sep/2024:10:17:02 -...
1
vote
3
answers
117
views
Loop ip list through geoiplookup and delete lines that do not match criteria
Thanks in advance for any ideas you present.
My current project has me trying to loop a file containing a list of 1000's of IP addresses through geoiplookup and piping it to sed to delete all lines ...
0
votes
2
answers
157
views
Displaying the sed command before its execution in a Bash script
I need advice on how to make every command I run in a Bash script first display itself and then execute. I created a simple function and a subsequent sed command to uncomment lines in the pacman.conf ...
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 ...
-1
votes
1
answer
50
views
Formatting the input file with Sed to Output but generating empty gilr [closed]
I’m having an input file with one million records and formatting and writing to another file to a different location but some times it is writing empty file(intermittent).
Following is the scenario:
...
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 /...
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 ...
-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....
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:
...
-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 ...
2
votes
2
answers
328
views
Search and replace composed Unicode characters
I have a deep folder structure on a Debian machine
where the directory names and the filenames
contain some "special" characters (ä,ö,ü).
However, these are not in "ISO-8859-1"
...
3
votes
3
answers
873
views
Add a tab to the beginning of lines stored in a variable
I am working on a script that will process a .zip file received from clients. It is common in my job to want the contents of the .zip file received listed within a log file as a means of validation. I ...
-1
votes
5
answers
343
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 ...