All Questions
971 questions
0
votes
2
answers
69
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
votes
2
answers
62
views
extract multiple words from git log
I need to extract multiple words from git log.
I need the commit id and ticket number for each commit, I then need to run this through a loop and do some further processing for each commit.
commit ...
11
votes
3
answers
2k
views
Why can't sed change /dev/zero's output characters to something else?
This works
head -c 10 /dev/zero | sed 's/\x0/x/g'
and generates xxxxxxxxxx as expected.
Then I tried this:
sed 's/\x0/x/g' /dev/zero | head -c 10
which seems to just hang.
Then I thought, oh, sure, ...
0
votes
2
answers
129
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 ...
-1
votes
1
answer
53
views
How to add escape character with bash?
I want this
{@codeBlock: TEstBigquerry.buildPicks}
to become
\{@codeBlock: TEstBigquerry.buildPicks/}
I tried
sed -i '/{@/\{@' joana.txt
got
sed: -e expression #1, char 5: unknown command: `'
how ...
2
votes
1
answer
455
views
Extract file path from Git diff output
I have the following command:
git diff branch1..branch2 | grep '^diff'
...that will output files that contains differences between two branches. Sample output is like this:
diff --git a/path-to-file1/...
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
2
answers
103
views
Replace multiple lines in a file with another command
I can find all files in a directory with a particular name with find:
find . -name hello.mk
Inside each hello.mk I need to replace lines 9 and 10 with a single line, as shown below:
9: ...
0
votes
1
answer
139
views
Replace string in file without temp file
I have a multi-gigabyte text file and I want to replace all occurrences of utf8mb4_0900_ai_ci in it with utf8mb4_unicode_520_ci.
Usually, I’d use sed -i for this as suggested here: find and replace a ...
0
votes
1
answer
81
views
Why does this sed command not work with "?" and "+"?
I'm trying to filter IP addresses from the ip a command via sed. When I write inet6* it works. When I write inet6? it doesn't find the match.
With *:
$ ip a | sed -ne 's,^ *inet6* \([^ /]*\).*$,\1,p'
...
-2
votes
4
answers
112
views
How to get either a substring or a text value using awk and if?
I can't figure out how to write a simple ping log. I only need either the ms value or the words "no connection".
I have myping=$(ping -c 1 10.0.10.1). I only need the value between "...
0
votes
2
answers
116
views
How to copy the value from one "column" to another in Bash?
I have a file with lines:
username="user1" email="[email protected]"
I need to take the username from the email address and replace the username value with it,
so the end result ...
2
votes
5
answers
531
views
Move line matching string to top of the file
Need to move single line with PRM:TRG keyword to top of the file using sed
File content:
FOOBAR:SCN:NO_TRG
FIZZBAR:SCN:NO_TRG
BEBAR:PRM:TRG
Output expected:
BEBAR:PRM:TRG
FOOBAR:SCN:NO_TRG
FIZZBAR:...
-2
votes
2
answers
50
views
Remove last 9 character in alternate lines of file in unix
I need to remove last 9 character from a file starting from Line number 4 and remove only on alternate lines 6,8.. like that to last Line of file
-1
votes
3
answers
98
views
Delete 2-line paragraphs, keep 3-line paragraphs, maintain newline between all
On a Linux machine with GNU tools I have an ascii file that consists of only 2-line and 3-line paragraphs, each paragraph separated by a newline. All 2-line paragraphs are to be deleted so that all 3-...