Skip to main content

All Questions

Tagged with
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 -...
kojow7's user avatar
  • 309
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 ...
Suggorath's user avatar
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 /...
user447274's user avatar
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 ...
Vija200's user avatar
0 votes
1 answer
169 views

Whats the meaning of this sed command sed '/^[[:space:]]*$/d'

I came across this sed command in a script to compare a machine's local binaries to GTFObins binaries. for i in $(curl -s https://gtfobins.github.io/ | html2text | cut -d" " -f1 | sed '/^...
M4raa's user avatar
  • 13
2 votes
1 answer
396 views

Escape special characters from variables [duplicate]

I have #!/usr/bin/bash search="ldo_vrf18 {" replace="$search"' compatible = "regulator-fixed"; regulator-name = "vrf18&...
Bret Joseph's user avatar
-1 votes
3 answers
168 views

Replace new lines at end for those lines whose 2nd field in colon separated file span over to multiple line

I have got multiple files with different set of contents but the pattern is same across mulitple lines in different files. sample input file : cat -n test.txt 1 adjfkhjdhfkjd: ...
Ashis Sahoo's user avatar
0 votes
1 answer
310 views

compare 2 csv files using specific column and ignore specific string

My OS: RHEL7.X I've a csv file with 3 columns, like so - #######Category: Fruit Berries are fruit,04415bef-8c82-4672-848a-9ac80035040a,"Blah/Blah And/More/Blah" Apple is a fruit,073c6bf3-...
Raman Kathpalia's user avatar
0 votes
0 answers
27 views

sed used in the function of the bash script fails [duplicate]

I use this bash script sed_no_ocr.sh which has no x property (i.e. ls -al sed_no_ocr.sh shows -rw-r--r--): #! /bin/bash file=$1 concatenation(){ echo "sed -i -r -e 's/($1) ($2)/\1\2/;p' $file&...
An5Drama's user avatar
  • 173
0 votes
2 answers
141 views

Remove command line options (mode-flags w/ options) from single line string in file

File mkisofs has the following one line string: xorriso -as mkisofs -r -checksum_algorithm_iso sha256,sha512 -V 'Debian 12.0.0 amd64 n' -o /srv/cdbuilder.debian.org/dst/deb-cd/out/2bookwormamd64/...
Jeremy Burcham's user avatar
0 votes
2 answers
130 views

Is it bad practice to use sed to pass a variable through to another script? [closed]

There are two shell scripts. One of which is a source file source.sh. This source file will exist for multiple people each with their own directories. name = "foo" The main script main.sh ...
Asteck's user avatar
  • 5
-1 votes
2 answers
110 views

Combine multiple lines starting with same phrase into one

I'm writing a Bash script to convert Arch Linux packages into a format for a package manager I'm writing, and I have to convert some metadata files into file format .toml. Previously, I've been using ...
universeindex's user avatar
3 votes
2 answers
204 views

Indent Fortran source code, propagate indentation down to unindented special lines

I'm trying to write my own script to improve some auto-formatting before commiting to a remote repository. I use indenting guides in my IDE and the autoformatters available for my language (FORTRAN) ...
Philip Moloney's user avatar
4 votes
1 answer
1k views

Execute the output of sed as a bash script that takes inputs

sed 's/docker/sudo docker/g' ./generate.sh | xargs bash I want to run a script generate.sh with all docker calls replaced with sudo docker, as just as it would have been ran if I called bash generate....
Noel Jacob's user avatar
2 votes
3 answers
1k views

How to use sed with variable, when the variable is random (certificate) text

I'm trying to make a bash shell script that mounts, from some pre-obtained variables, a text file. For this I use sed, changing the flags of the file by the desired: sed "s/this is a line in text/...
Francisco de Javier's user avatar

15 30 50 per page
1
2 3 4 5
15