Skip to main content

Questions tagged [shell-script]

Questions about shell scripts, executable files that are interpreted by a shell (bash, zsh, etc.). Check scripts with https://shellcheck.net before posting.

-2 votes
0 answers
22 views

Creating in Linux files in GB or MB range by various size by read a file

In Linux with Bash, there is the File numbers_in_one_line. In this file there is only one line with several numbers, all separated by spaces. These numbers are the value in bytes for creating files ...
user447274's user avatar
0 votes
1 answer
33 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
12 votes
1 answer
2k views

Why does cd '' succeed in bash?

Maybe I'm missing it, but I don't find it documented that cd '' should succeed. Since there is no directory with the name '', it seems obvious that it should fail. For example, mydir= cd -- "$...
jrw32982's user avatar
  • 1,069
0 votes
0 answers
47 views

How should one choose whether to utilise ~ or $HOME? [duplicate]

Context When utilising the IEEE Standard 1003.1-2017 Shell Command Language, I frequently want to reference the value which $HOME contains. However, two methods of dynamically acquiring the path are ...
RokeJulianLockhart's user avatar
-3 votes
1 answer
96 views

bash -n is a not documented in manpages or info documents [closed]

Even though bash -n is a valid and widely used option, some manpages don't clearly document it in the bash options section, even though it is implemented. It's also not in the GNU Bash Reference ...
bit's user avatar
  • 1,166
0 votes
1 answer
83 views

How to create splittet random files and join them with dmsetup

In Linux in Bash, there is a script, a part of the script is this while true ; do echo awk -v x=$(<"$TEMPDIR"size_container_in_byte) -v n=$(<"$TEMPDIR"parts) 'BEGIN{...
user447274's user avatar
0 votes
1 answer
103 views

How to compare output of a program with a reference value in a shell script?

I have my own implementation of a Redis server which I'd like to test through a shell script. The general idea is to feed it with some commands through nc, and since nc prints the output of my program ...
ivanbgd's user avatar
  • 111
0 votes
2 answers
97 views

How to redirect output from a program that waits for input

Following this post I created my own version of the script, with the difference that user and password are forwarded from the environment variables: #!/bin/zsh pamtester login $user authenticate <&...
Namal's user avatar
  • 101
0 votes
2 answers
87 views

how do i use pv in a script that has a seq for loop

I have a script that has a for loop in it that runs a specific amount of times, and I was wondering if it is possible to implement the pv command in my script to add a progress bar. Here is my code: ...
harry mckay's user avatar
-1 votes
1 answer
32 views

How do you know if a package would be upgraded or downgraded by apt?

If you are about to run command sudo apt-get install --allow-downgrades <pkg>/<target-release> how do you know if the package would be downgraded or upgraded before running the command? I ...
jarno's user avatar
  • 716
-7 votes
2 answers
93 views

How can I pick random items from a list, but some more often than others, in a Bash config file? [closed]

In Linux, using Bash, I have two scripts: script.sh is the main script, and script_config.sh is the configuration for script.sh. In script.sh, I do source script_config.sh to load all the config ...
user447274's user avatar
0 votes
2 answers
85 views

List and count ciphers used by cryptsetup in /dev/mapper devices

In my Linux Computer there are many files called file1, file2, file3 ... in /dev/mapper/. Now I want to have an overview from the files what cipher is used how often. I tried this for i in /dev/...
user447274's user avatar
-1 votes
2 answers
82 views

How to analyse a number of different datasets with a script and save the output for each dataset in a different new directory?

I am interested in analysing 50 different datasets with a script and saving the output of each of the 50 analyses in 50 different corresponding directories. To avoid doing this manually, how could ...
Carlos Fernandes's user avatar
0 votes
2 answers
79 views

How to "catch" the output of a command? [duplicate]

I'm struggling with the vocabulary here, so I'll ask this way: On an embedded system (Raspberry Pi) I use, there is a command invoked as follows: $ pin-control poll 25 This command "polls"...
Seamus's user avatar
  • 3,727
5 votes
1 answer
808 views

My bash script keeps telling me my directory doesn't exist even though it does [duplicate]

I have a script and when I run it, it returns Directory not found: ~/Pictures/Wallpaper The script is as follows: #!/bin/bash # Check if the wallpaper directory exists if [ ! -d "$WALLPAPER_DIR&...
PrismaPixel Studios's user avatar

15 30 50 per page
1
2 3 4 5
1110