Skip to main content

All Questions

Tagged with or
Filter by
Sorted by
Tagged with
3 votes
2 answers
154 views

tl;dr: How to reliably ensure that the pipe a | head -n1 terminates as soon as head terminates? Motivation: git log --grep="$MAIL_SUBJECT_LINE" --oneline --format=%H | head -n1 takes a long ...
teapot's user avatar
  • 361
0 votes
0 answers
82 views

I am trying to launch 2 nodes from a .service file on Ubuntu 22.04. The service file looks like: [Unit] Description=ROS2 Battery and Dock Monitor Nodes After=network.target [Service] Type=oneshot ...
John Miller's user avatar
0 votes
2 answers
141 views

I'm writing a script as part of a process to restore a broken environment. It sources a couple of other scripts, and I want all of those variables to be maintained on the command line after running ...
user2013318's user avatar
2 votes
3 answers
725 views

I have large file with list of hosts. I remote to the severs to extract a variable which can end with odd or even number. I am running a for loop to execute same action(restart) on all variables ...
MO12's user avatar
  • 409
0 votes
1 answer
77 views

I'm trying to accomplish a simple task and getting stuck. I've written a very simple script #!/bin/bash cd /Users/nathan/Downloads/ mv test test2 mkdir test This works when I manually invoke it. But ...
Nathan's user avatar
  • 1
-1 votes
2 answers
96 views

Update: Up to 2 "/" in the string. String structure is either: Character set name/LF Character set name/CRLF Character set name/CRLF/(unknown purpose, likely a number) Character set name ...
strider's user avatar
  • 113
0 votes
0 answers
65 views

I have an issue with scope of ssh-initialization. I have following script for ssh-init.sh: #!/bin/zsh check-ssh-agent() { [ -S "$SSH_AUTH_SOCK" ] && { ssh-add -l >& /dev/...
Eugene Shtoka's user avatar
4 votes
3 answers
268 views

I'm dealing with a series of bed files, which look like this: chr1 100 110 0.5 chr1 150 175 0.2 chr1 200 300 1.5 With the columns being chromosome, start, end, score. I have multiple different files ...
Whitehot's user avatar
  • 245
1 vote
2 answers
198 views

I have a directory structure like this: dir1/ 732842342.mp4 screenshot1.png dir2/ 324324234.mp4 screenshot2.png dir3/ 121321321.mp4 screenshot3.png What I'm trying to do is ...
Andy's user avatar
  • 603
5 votes
4 answers
994 views

I'm trying to build a wrapper to execute a tool multiple times, then concatenate some of the results. I'd like to pass two sets of files to my wrapper script, then run the tool for each pair of files. ...
Whitehot's user avatar
  • 245
-1 votes
1 answer
176 views

I need to install something that allow me through a script bash or if I can do it without install any external tool it would be great. The thing is I read about csvkit but is a tool of python and i ...
user714955's user avatar
2 votes
2 answers
333 views

I'm a Unix newbie so I apologize if the solution to this question is too easy. I'm interested in running a script a number of times (because the process/algorithm doesn't produce exactly the same ...
Carlos Fernandes's user avatar
0 votes
0 answers
19 views

Well-behaved apps add the files they are saving to .local/share/recently-used.xbel so that they are easily retrieved when using another app (for instance, browser for upload). So, if a shell script ...
xenoid's user avatar
  • 9,348
3 votes
1 answer
980 views

I've created a makefile command to automate a publishing workflow using Pandoc and the Generic Preprocessor (GPP). It is as follows: TODAY = $(shell date +'%Y%m%d-%H%M') MACROS = utils/gpp/macros.md ...
Khalid Hussain's user avatar
1 vote
3 answers
196 views

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 ...
user avatar
0 votes
1 answer
64 views

Consider the 2 bash commands below: $ VAR="hello world" $ ./script.sh "$VAR" Line 1 stores the string hello world (quotes removed) to parameter VAR. Line 2 should be processed as ...
yossi-matkal's user avatar
0 votes
1 answer
94 views

As a somewhat new user, I recently discovered the trick of opening the current terminal line in $EDITOR, using the hotkey C-x C-e. This has changed my life, and has made writing loops and such much ...
supersquires's user avatar
1 vote
3 answers
2k views

I just recently downloaded Linux, and overall it's not too bad, but I just have a question about .sh files and how they work: when it comes to other files like .py, usually you'd be able to run them ...
AuraWare's user avatar
0 votes
3 answers
290 views

I have tried the following to no avail, the script just stops after the first input. filename="..." while IFS="" read -r line; do echo "$line" | nc <target> <...
Jarrett GXZ's user avatar
0 votes
0 answers
44 views

I have a shell script that I want to run many times. Each time, I want to use a different argument that comes from a CSV file. The file is very simple: code1-code2-01 code1-code2-02 code1-code2-03 ...
David Orozco Cosio's user avatar
0 votes
2 answers
96 views

What is the find script to sort a subtree into files with the most recent modification time? Also preserving their path name? I suspect it has something to do with find, ls, awk and sort. I haven't ...
atod's user avatar
  • 155
0 votes
1 answer
120 views

...that is to say, is there a means by which I can read the full command that's being evaluated AS it's happening? Here's a contrived example, but one I feel makes the question clear: function ...
NerdyDeeds's user avatar
0 votes
0 answers
63 views

How do I accomplish this command to redirect command output to multiple files, without retyping the later A=1>&/dev/tty 1>&${TMP}/lastcmdout every time? I want to see output on the ...
Nick's user avatar
  • 205
0 votes
1 answer
132 views

I try to make a simple script that pings a network connection: #!/usr/bin/env bash # Xdebug ip detector for docker # Copyright (C) 2023 Dimitrios Desyllas # # This program is free software: you can ...
Dimitrios Desyllas's user avatar
0 votes
0 answers
59 views

I have problems with replacing parentheses in combination with variables, in ssh. For instance, replacing (hello123blablabla) with (hello). So, it replaces all together, and parentheses as well, at ...
armagedescu's user avatar
1 vote
1 answer
147 views

I have a simple bash script that's supposed to create a dump file from a database docker exec -i container sh -c "mongodump --archive" > \ ~/dumps/db-$(date + "%d%m%Y").dump ...
Ambre's user avatar
  • 111
-5 votes
1 answer
107 views

to make a script more secure, we would need to confirm that used cmds, eg.: "/usr/bin/chown" instead of just "chown".
robert8819's user avatar
0 votes
1 answer
73 views

I have an ssh .sh bash script file i'm running on a cron to check website status. The bash script (when ran) refers to a local txt file for a list of websites to check if they're down or up. ...
sven30's user avatar
  • 103
-2 votes
2 answers
344 views

I was plodding along, working on a shell script, and I've just learned something that I found surprising. I'm presenting it here as a Question because I'd like to learn if there's some way to avoid ...
Seamus's user avatar
  • 3,928
0 votes
2 answers
157 views

Writing a quick bash function to change the network TTL (for tethering from a phone,) but as it turns out, it's a slightly different command for each system so to accomodate the logic, my simple ...
Vita's user avatar
  • 320
0 votes
0 answers
31 views

I am working on creating a way to right click on an .eml file, right click, and have python pull two pieces of data from it and paste them into a new xlsx file and auto open the xlsx file. I would try ...
Coo's user avatar
  • 101
12 votes
2 answers
2k views

I need to run multiple shell scripts sequentially (s1.sh, s2.sh, s3.sh) with the following requirement: If a script produces no output (stdout or stderr) for 1 minute, it should be terminated After ...
Just a learner's user avatar
0 votes
1 answer
195 views

I'm writing a shell script that changes its behavior based on the number of positional parameters passed script.sh if [ $# -eq 1 ]; then if [ -f "$1" ]; then validate='validate <&...
killua148's user avatar
4 votes
2 answers
846 views

In almost all POSIX specifications (e.g. ls), there are only short options (e.g. -A , -a , etc). In common shells like Bash, long options (e.g. --all , --almost-all , etc) are very common. And it is ...
midnite's user avatar
  • 613
0 votes
1 answer
817 views

I have a shell script on my host, which is calling another script to run inside the container. Here is a simple case that works fine: host_script.sh #!/bin/sh results=$(docker exec mycontainer "....
teeeeee's user avatar
  • 305
-2 votes
3 answers
235 views

I try to uncomment specific lines from a file with patterns in oracle linux 8.6 using bash. There are leading white spaces on certain lines where the comments are not removed. I tried to uncomment the ...
Kishan's user avatar
  • 113
-1 votes
1 answer
195 views

I have log patterns every day for artemis I want to zip them and delete the files and save one month files in one zip the files like this artemis.log.2024-11-22 artemis.log.2024-11-23 artemis.log.2024-...
MohammadReza Arefi's user avatar
0 votes
4 answers
287 views

Can someone clean up this part of bin bash script for me? I feel like i can write this so much cleaner. Basically, what i want to do is: If $pluginexcl2 is defined that 2 different grep -v will be ...
Shamir Husain's user avatar
12 votes
2 answers
2k views

Some of my coworkers prefer to write the following at the top of their BASH scripts to determine the directory containing the script: SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}&...
villapx's user avatar
  • 844
0 votes
1 answer
120 views

I'm looking for a way to provide custom/configurable randomisation to a slideshow tool like impressive or feh (something lightweight I can run automatically at startup). Basically I need to weight ...
fjdksflds's user avatar
0 votes
1 answer
75 views

I am starting a screen session in my entrypoint shell script in docker, then log the output of screen -list to a file. #!/bin/bash screen -S my_screen -dm bash -c 'cd project && npm run start'...
Z0q's user avatar
  • 631
0 votes
2 answers
186 views

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
1 vote
1 answer
203 views

with the following command line, which I turned into an alias, I would like to open the pdf files from my terminal. alias pdfLoad="fd . '$HOME/OneDrive/DBCalibre' -t f -e pdf | fzf | xargs -0 -I ...
Salvatore Di Fazio's user avatar
0 votes
1 answer
281 views

I want to apply commands below to all files in a directory instead of one file. cat file.txt | sed -E "s/\@([0-9]+)\W+~(.*?)/\1 \2/g" | tr -d '~' cat file.txt | sed -E "s/\@([0-9]+).*\~...
user1002601's user avatar
1 vote
2 answers
86 views

I have a script that syncronizes folders. The script does /usr/bin/rsync -av --delete $SOURCE $DEST >> $LOG_FILE 2>> $ERR_LOG_FILE so it redirects output to LOG_FILE and error output to ...
klatls's user avatar
  • 53
0 votes
1 answer
52 views

I am trying to sort an inventory list in unix/linux below. I am successful in sorting by name and ID and able to pull up the usage menu but cannot sort by price, even with an "awk" function....
Natasha Shorrock's user avatar
0 votes
1 answer
70 views

Is there a way via script to set an alert when an application is sending high volume of messages in short amount of time (5min)? My goal here to have us notified when some application spamming or ...
manwithamission's user avatar
0 votes
2 answers
136 views

I'm going through the "sed & awk" book by Dougherty and Robbins. One of the examples calls for piping output to a shell script: sed -f nameState list | byState But I've found that, in ...
Mike's user avatar
  • 290
2 votes
1 answer
98 views

When trying to get the PID of a shell command, it is possible using a script file: #!/bin/bash ls -lha & echo "$!" However, it is not possible using only the terminal. /bin/bash -c 'ls ...
danieltakeshi's user avatar
2 votes
3 answers
129 views

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 ...
learningregularexpressions's user avatar