All Questions
45 questions
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 ...
-1
votes
2
answers
141
views
how to de-duplicate block (timestamp+command) from bash history?
I'm working with bash_history file containing blocks with the following format: #unixtimestamp\ncommand\n
here's sample of the bash_history file:
#1713308636
cat > ./initramfs/init << "...
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 ...
2
votes
2
answers
2k
views
Sed based on 2 words, then replace whole line with variable
I have a txt file looking like this,
1:Ana:apple:08:00:wait
1:Joe:banana:08:30:wait
1:Oscar:orange:08:45:ready
1:Monica:apple:08:50:ready
1:Mark::orange:ready
I have to find only the first line that ...
1
vote
1
answer
112
views
How to delete a string in my files?
So I want to match all below then remove those lines of string.
[MTT-5634](https://my.atlassian.net/browse/MTT-5634)
[MCC-123](https://my.atlassian.net/browse/MCC-123)
[MTT-7965]: https://my.atlassian....
0
votes
1
answer
971
views
reload the i3 conf in a script
i am writing a script to quick change the mod key of i3
conf0="/home/myuser/.config/i3/config"
case "${1}" in
(alt) key=Mod1 ;;
(win) key=Mod4 ;;
(*) printf "Invalid ...
0
votes
1
answer
836
views
Only perform sed operations on lines starting with a particular string [closed]
I have the following file format
Received from +11231231234 at 2021-10-10T19:56:50-07:00:
This is a message that contains words like from, at, etc.
Sent to +11231231234 at 2021-10-11T06:50:57+00:00:
...
2
votes
2
answers
2k
views
sed with external script file - How to apply shell variables?
Directly on the command line, this works:
$sed "s/a/X/;s/X/&a&/" file
and so does using shell variables:
$varin=a ; varout=X ; sed "s/$varin/$varout/;s/$varout/&$varin&/...
0
votes
1
answer
103
views
Error with sed replacing string
Hello I need to replace a string but i receive error using string 'return false;'
#!bin/bash
oldstring='{alert("bash")}'
newstring='{return false;}'
grep -rl $oldstring /home/commons.bundle....
0
votes
1
answer
45
views
How to differ strings with and without ending/starting spaces? [duplicate]
I need to format a text file (a Fortran source code) and change some keywords from small letters to capitals or vice versa.
I've made an array of possible keywords and have the following piece of the ...
0
votes
1
answer
130
views
How can I copy lines from a file every 60 seconds, and continue from last copied
I need to copy x lines from a file every 60 seconds, and after 60 sec, continue to copy for another 60 sec, restarting from last copied?
#!/bin/bash
while true; do
sed -n -e '1,10000' input.yml > ...
1
vote
2
answers
1k
views
How to join columns from two files using awk/sed command?
I have two files File-1 and File-2 with data in columns. I want to create another file and copy the data of the first column of File-2 corresponding to the data to file-1 in row wise as given below.
...
0
votes
1
answer
223
views
sed :unknown option to `s' in my sed script [closed]
So i have a script named SED.sed. The script was made to work on a data set of car data, to clarify i want to first explain the desired function for my script.
I want to do 3 things
replace years ...
0
votes
1
answer
59
views
Replace string with newline and add text
This one is probably easy, but cant figure it out, I want to replace <BR> with newline and add https:// behind example.com
example:
https://www.google.com<BR>example.com
would become:
...
-1
votes
2
answers
49
views
Copy last numeric part of a file name to the beginning
ISS45_20200302030042.zip
R0387F200229.zip
I want a shell script for this scenario. Above are the two file names I want something like this. I want digits part to be prepended to the front of the ...