Skip to main content

All Questions

Tagged with or
Filter by
Sorted by
Tagged with
1 vote
1 answer
121 views

I read somewhere that in a shell script the [..] construct like for example [ -e $HOME/temp ] is POSIX compliant. While the script [[..]] construct like [[ -e $HOME/temp ]] is not. Is this true? Apart ...
KDM's user avatar
  • 128
0 votes
1 answer
1k views

I have an application which is making automatic daily backups at 11pm in a directory dirA. Each backup is a single .tar file, and has an apparently random naming convention that I don't have control ...
teeeeee's user avatar
  • 305
0 votes
3 answers
146 views

Sequentially one after another: for i in $(ls -1) ; do command $i ; done All at one time: for i in $(ls -1); do \ ( \ command $i ; done ; \ ) & \ done; wait How to say only for example 4 or ...
user447274's user avatar
2 votes
1 answer
905 views

I tried to use a bash script to add or remove proxies in bulk, but the script runs with confusing results. I can add proxies in bulk using the following code. This code is saved by me in use_proxy.sh: ...
dja kkk's user avatar
  • 21
3 votes
2 answers
702 views

I came across some weird behavior when using the wait command for running parallel jobs in a bash script. For the sake of simplicity I have reduced the problem to the following bash script: #!/bin/...
Dylan Callaghan's user avatar
3 votes
1 answer
455 views

I have a super complicated bash script that extracts results from a large output file (produced on a LINUX machine, just in case this is relevant). As part of this process, I use combinations of grep, ...
r.g.'s user avatar
  • 33
6 votes
3 answers
1k views

This code works fine on Linux but not Mac OS: #!/usr/bin/env bash foo=$(cat <<EOF "\[^"\]+" EOF ) printf "%s" "$foo" It fails on Mac with ./test.sh: line 6: ...
Jason Gross's user avatar
0 votes
1 answer
63 views

find . -name 'Vol_*.tif' -print0 | sort -z -V | xargs -0r img2pdf -o out.pdf CAS wrote above and with this I was able to solve my needs. One extra feature: For each TIF file I would like to print on ...
Carlo Albrile's user avatar
0 votes
1 answer
235 views

There are the following ways to check if a variable is available or not in a linux/unix shell script [ ! -z "${MYVARIABLE}" ] OR [ -n "${MYVARIABLE}" ] OR [[ ! -v MYVARIABLE ]] ...
KDM's user avatar
  • 128
2 votes
2 answers
496 views

I am physically connected to the machine an I use Arch linux. I use Arabic in the terminal and I use BiCon to add bidirectional support for the terminal (I am using st). I want the program to start ...
N0tus3r's user avatar
  • 43
1 vote
0 answers
39 views

Lets take a look at my example bash -c 'echo $#' _ x gives 1 bash -c 'echo $#' _ x _ y gives 3 why?
MikiBelavista's user avatar
1 vote
5 answers
468 views

I am trying all the methods but I get this error: I want to convert this format to epoch --> date "+%Y%m%d%H%M%S" example --> 20240913235959 I also tried other formats such as: date &...
Navid Taghavi's user avatar
1 vote
3 answers
78 views

I am trying to extract a value (nread) from sysctl, but only for a specific dataset_name. What is the most efficient way to do this with a shell script? Example sysctl output (via "sysctl kstat....
tacgnol's user avatar
  • 63
1 vote
2 answers
277 views

I'm using git bash, so I suppose it's ok to ask questions in Unix forum, but I'm not familiar with Unix, only use ls, find and grep, so pls correct me if I'm wrong. I have hundreds of .csv files and ...
athos's user avatar
  • 125
4 votes
2 answers
708 views

I have tried a combination of: v4l2loopback ffmpeg mpv But either the web-cam view, or the web-cam record works, but never both together. Can anyone provide a script that achieves this? This is what ...
Brad's user avatar
  • 331
2 votes
2 answers
799 views

Can I give GNU date a date and format string for that date and tell it to also subtract some time from it? It seems I can do 2 of 3 in 1 command but not all I have this date format: 09/Sep/24 05:02 AM ...
Christian Bongiorno's user avatar
0 votes
0 answers
60 views

I'm struggling to make this script run correctly more consistently. I wrote this Bash script that copies a selected, highlighted quote in Zotero (a source manager), and copies that quote into Obsidian ...
ReaderGuy42's user avatar
0 votes
0 answers
90 views

When I call the script (via commandline) I'd like to pass in an optional list of directories for the find command to ignore. This is what I have but my output includes data from files in the ...
Kaverni's user avatar
3 votes
1 answer
642 views

EDIT: sorry. this is my first question here. Here is a minimal working example #!/bin/bash # count=0 function something() { if test -f "$1"; then # is a file ((count++)) ...
Shlomo V's user avatar
1 vote
6 answers
899 views

I would like a bash shell script (for my Debian 12 system) which accepts multiple paths as arguments, and then checks if a file can be successfully created in each one. Then the result should be put ...
teeeeee's user avatar
  • 305
0 votes
2 answers
2k views

I am running the following script in Ubuntu 22.04: #!/bin/bash logfile="/absolute/path/to/log.txt" find /absolute/path/to/haystack -type d -name "needle" -execdir sh -c 'pwd > $...
Borea Deitz's user avatar
0 votes
2 answers
126 views

I have multiple of text files containing values like this: width = 64 height = 128 position_x = 48 position_y = 48 I would like to go over this files, and multiply those values by 2, producing a file ...
Marko's user avatar
  • 23
1 vote
1 answer
264 views

I have script script.sh: #!/usr/bin/env bash # pm2 seems to always run in `bash` regardless of `#!` echo "running in $(readlink -f /proc/$$/exe)" # Redirect to both stdout(1) and stderr(2) ...
Amith's user avatar
  • 323
6 votes
3 answers
1k views

This problem is driving me crazy. From the command prompt I can enter this command and it works as expected (records where the INFO/RegionType tag contains the value Core are emitted in the output ...
mcrepeau's user avatar
0 votes
1 answer
139 views

We have a ksh Script that is suppose to give the output as last day of the month but when ever we run it we get the below error: cut: fields are numbered from 1 Try ‘cut —help’ for more information, ...
ZyPH3R's user avatar
  • 3
0 votes
1 answer
103 views

Is it possible to reliably check with a shell-script if a directory was deleted and later recreated with the same name in Linux? Depending on the filesystem one could check for a change in the inode-...
mab0189's user avatar
  • 121
2 votes
2 answers
226 views

Awkard way to pharse it in the title ik. I'll break it down better so that it makes sense. I have a file that says: abab baaa babb I need to read each character of a line into a register ...
Victor prokop's user avatar
3 votes
2 answers
322 views

I have files that contains multiple functions like below. file1.c: static void function1() { code } ... static void functionX() { code } ... static void lastFunction() { code } file2.c: ...
aWLW's user avatar
  • 133
0 votes
1 answer
359 views

I need to write a script to count how many 2 or 4 port HBA cards we have in each of our servers. I'm running lspci on each of the servers, however, none of the documents I've read so far is telling me ...
Classified's user avatar
0 votes
2 answers
99 views

How do I quickly preview what a locale looks like? E.g: is there something like $ localepreview en_DK.UTF-8 Of course, I immediately think of a script like #!/bin/bash LOCALE=$1 export LANG=$LOCALE ...
AvidSeeker's user avatar
0 votes
1 answer
229 views

I have the following line: isUbuntu=$(cat /etc/os-release | grep '^ID=ubuntu$' | wc -l) It works fine Now, through VSC and mostly with the ShellCheck extension is indicated two warnings messages as ...
Manuel Jordan's user avatar
-4 votes
1 answer
119 views

I want to move all .XML files in the current working directory whose name starts with DAPRETAIL followed by the current date in YYYYMMDD format to a separate directory. I tried: DATE='date +%Y%m%d' mv ...
AryanG's user avatar
  • 1
2 votes
2 answers
386 views

I was working on an array job for a small pipeline, and I happened to need a way to execute a specific command based on file size. I found this post and similar which describe how to do it. At the ...
Matteo's user avatar
  • 387
0 votes
3 answers
203 views

This is what happens. I manually and successfully mount my USB drive using mount /media/usb from outside a shell script which I wrote. Therefore, the drive is working and mounted normally. The very ...
superlinux's user avatar
0 votes
0 answers
719 views

This is probably the strangest error I've run into. So I'm running a Wikibase Docker setup on a Windows machine. The Docker containers are all Debian OS. In order to install some packages upon setting ...
user3684314's user avatar
0 votes
2 answers
162 views

man mktemp: The mktemp utility is provided to allow shell scripts to safely use temporary files. Traditionally, many shell scripts take the name of the program with the pid as a suffix and use that ...
jsx97's user avatar
  • 1,397
0 votes
1 answer
2k views

I have tried #!/bin/bash distro="" myvar1=[[ -n "$distro" ]] && echo $distro || echo "debian" myvar2=$((-n $distro ? $distro : "debian")) these are ...
mrjayviper's user avatar
  • 2,303
1 vote
3 answers
207 views

I have a simple script for the i3 window manager that shows an i3bar at the bottom of the screen when you touch its edge with the mouse. It almost always works fine. However, after it quits, there is ...
Anton Vakulenko's user avatar
1 vote
1 answer
163 views

For context, I have some experience with Unix and basic commands, but I'm seriously struggling to conceptualize more complex manipulations of files. Essentially, I have this command I want to run from ...
avery's user avatar
  • 11
0 votes
0 answers
125 views

I'm running a simulation for a project.  Each simulation run generates many .dat files.  So, essentially, I'm getting Z_image_000.dat to Z_image_276.dat.  I'm running multiple simulations in a day, so ...
tbt's user avatar
  • 1
0 votes
1 answer
108 views

So i have something along the lines of: set -eo pipefail ssh localhost "ls; exit 1" | cat > output I thought pipefail would prevent cat to write to ouput (because of the exit code from ...
PKSWE's user avatar
  • 103
0 votes
0 answers
57 views

I have a 3 part logic (A or B and C). Logically if A is true then true, or if B and C is true then true; But here is the error if (A or B and C) -> should return true if [ 1 -eq 1 ] || [ 2 -eq 2 ] ...
Trần Quốc-Bình's user avatar
1 vote
0 answers
189 views

I'm writing a script that I run directly, "source" from the bash console, or cut/paste as a sequence of commands into a console from an editor window. The script or its pasted commands may ...
Russ's user avatar
  • 159
0 votes
1 answer
183 views

I am trying to programmatically customise various settings in the gedit application, and currently I've got the following command to change the colour scheme. gsettings set org.gnome.gedit.preferences....
hymcode's user avatar
  • 133
0 votes
1 answer
68 views

I'm abusing Make to run some tests for me, and I need to compare the output of a command against a fixed string, ideally with a somewhat readable construct. The best thing I can do if $SHELL is bash ...
Simon Richter's user avatar
3 votes
2 answers
523 views

Can I get the output of history sorted in order of most-used? I know how to do it in a programming language, but not from the shell. In my case I'm on macOS with zsh. I know I could use uniq and sort ...
hippietrail's user avatar
1 vote
1 answer
198 views

Basically I want to login in my system and let the system to open for me my Web browser (Thorium). Since I' using Ubuntu 22.04 and I want to start the browser as user (and not as root), I followed ...
Dave's user avatar
  • 133
0 votes
1 answer
126 views

I am making a system info script which will output what version of CentOS a machine is running. Currently, I have the following: #!/bin/bash distro=$(cat /etc/redhat-release) echo "OS Version: $...
hymcode's user avatar
  • 133
0 votes
1 answer
59 views

I have several directories that all have files in them. I want to count the number of files and then create subdirectories based on that count. Example 1: Main Directory +-> Subdirectory +->...
Jeramey Beck's user avatar
1 vote
0 answers
109 views

Some really weird Voodoo magic is going on with mdadm in my script: Creating RAID with: mdadm --create --run --level=1 --metadata=1.2 --raid-devices=2 /dev/md/4 /dev/nvme1n1p4 /dev/nvme0n1p4 mdadm: /...
HeartOfGermany's user avatar

1
3 4
5
6 7
336