New answers tagged

0 votes

Linux Bash Shell Script Error: cannot execute: required file not found

Docker Dev Containers This seems to occur if you clone a Git repository to a Windows file system, and then (using VS Code) open that directory within a Docker Dev Container In other words you might ...
user3728501's user avatar
0 votes
Accepted

SIGTSTP(Ctrl-Z) not working for script started by script command

Just like any other pass-through tool (ssh, screen, tmux, etc.), script puts the calling terminal into raw mode so that characters such as Ctrl/Z no longer generate interrupts. It then passes these ...
Chris Davies's user avatar
0 votes

How to replace lines which has no data with the previous line's data

Using Raku (formerly known as Perl_6) ~$ raku -e 'my @init = [Z=>] lines[0].words, (DateTime.new("2024-01-01T00:00:00Z"), "0.00", "Initial"); put @init....
jubilatious1's user avatar
  • 3,255
0 votes

How to replace lines which has no data with the previous line's data

Using Miller (mlr) to keep track of the timestamps and values from each record in the tab-delimited input, and insert an incremented timestamp and a new value in any record that has a NoValue flag: $ ...
Kusalananda's user avatar
  • 335k
0 votes

Mass Update of SSH Keys

as every server should have its own host key, shouldn't it? It should but if someone is using a golden image to implement the hosts or simply cloning an existing host an NOT regenerating the host key,...
symcbean's user avatar
  • 5,557
1 vote

Remove subdomains or existing domains

$ sed -e 's/\./\\./g' -e 's,.*,/\\.&$/d,' file | sed -f /dev/stdin file google.com bgoogle.com yahoo.co.uk stats.wikipedia.org media.wikipedia.org bible.com This first uses sed to create a sed ...
Kusalananda's user avatar
  • 335k
0 votes

Remove subdomains or existing domains

This might be what you're trying to do, using any awk: $ cat tst.sh #!/usr/bin/env bash awk ' { doms[$0] } END { for ( dom in doms ) { n = gsub(/[.]/,"&",dom)...
Ed Morton's user avatar
  • 31.7k
0 votes

Mass Update of SSH Keys

I don't think the message is strictly related to issued command. Probably remote hosts already had the same (old) keys, that you accepted once, yesterday or 10 years ago. When you removed those, new (...
realpclaudio's user avatar
0 votes

Remove subdomains or existing domains

Using Raku (formerly known as Perl_6) ...translating @terdon's excellent Perl solutions: ~$ raku -ne 'BEGIN my %k; %k{$0}++ for s/ .*? (<-[.]>+ \. <-[.]>+ $)/$0/; END .key.put for %k;' ...
jubilatious1's user avatar
  • 3,255
0 votes

Exiting a shell script with nested loops

An alternative to testing the exit status code of the pipe (as in the accepted answer) is to use process substitution. So instead of this: #!/usr/bin/env bash seq 3 | while read line_1; do seq 3 |...
Big McLargeHuge's user avatar
1 vote

Remove subdomains or existing domains

It sounds like your problem can be reformulated as "only keep the longest non-. followed by a . and the no other . until the end of the line; make these unique". If so, you can do something ...
terdon's user avatar
  • 242k
1 vote
Accepted

Running sudo, changing dir, staying in sudo, staying in dir after the script finished

I guess I've a solution, but it will create multiple processes. #!/bin/bash sudo -i bash -c 'cd /path/to/your/workdir && exec bash' The first process will be created by running the script,...
Amartya Sinha's user avatar
6 votes

Tool(s) for echoing to a bash script only once if script is run more than once

Before I show you how to solve your original question, first let me show you the proper way: If you have root permissions, you can simply install the files into the directories intended for this ...
Devon's user avatar
  • 922
-2 votes

Tool(s) for echoing to a bash script only once if script is run more than once

I would honestly just grep for the lines in question. If they are in there, don't do anything and, if not, add the lines. ex: line1=$(grep "asdf.bash" ~/.bashrc) if [ ! -z "$line1" ...
Manux's user avatar
  • 57
0 votes

How do I copy directory structure as symlinks inside other directory

There is an important caveat when creating symlinks that are meant to be tracked under Git. The reference path of the source file should be relative to the repository, not absolute to the machine. Not ...
killertofus's user avatar
-1 votes

cron "@reboot" schedule not executing network configuration script

The problem was that I was using my own user's crontab and regular users cannot run @reboot jobs. I used root's crontab (sudo crontab -e) instead and it worked as expected! Thanks everyone!
Strider's user avatar
1 vote

Mounting directories on demand or until logged

Regarding a possible solution resorting to some logout script, LighDM conforms to the freedesktop specification which, given this setting : [SeatDefaults] … session-cleanup-script=command … Will ...
MC68020's user avatar
  • 7,981

Top 50 recent answers are included