Skip to main content

All Questions

-1 votes
1 answer
80 views

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

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

How can a bash script determine how it was started? [duplicate]

I am running various scripts on Debian 12.X currently with the following bash: GNU bash, version 5.2.15(1)-release (x86_64-pc-linux-gnu) I have the following methods/options to execute the script. ...
ReflectYourCharacter's user avatar
-3 votes
1 answer
50 views

Rename files, remove the first four signs [duplicate]

There are many files in this format: IMG_20240717_191421.jpg IMG_20240620_165358_BURST001_COVER.jpg IMG_20240624_173513_2.jpg how can they renamed in Linux in Bash to: 20240717_191421.jpg ...
user447274's user avatar
0 votes
5 answers
128 views

Move/mark files and the associated-part too

There is a folder with many files in it: 112.mkv 123.md5 123.mkv 221.mkv 467.mkv aa1.mkv abc.md5 abc.mkv bbc.mkv dde.md5 dde.mkv ggh.mkv .... xxy.md5 xxy.mkv xxz.mkv How can I move .md5 files and the ...
user447274's user avatar
2 votes
1 answer
167 views

select in a script

In Linux in Bash in a Script i use this: #!/bin/bash while true; do while true; do read -r -p 'enter number [4-999]: ' num if [[ $num =~ ^([4-9]|[1-9][0-9]{1,2})$ ]]; then ...
user447274's user avatar
-4 votes
2 answers
110 views

How to write in Linux in Bash in shellscript a part that can do something like this

How to write in Linux in Bash in shellscript a part that can do something like this enter a number must be in a range from 4-999 if not, ask again to enter enterednumber * 5 * randomnumber [1-9] (...
user447274's user avatar
0 votes
2 answers
72 views

How to print the processed argument after each command invocation with xargs

i run this command: ls -1 | xargs -I% -n1 -P8 myprogramm -s1 -r5 -q -o %.dat % it works with 8 runs at one time, the -q switch in myprogramm for quit, that is ok so. but i will add something like ...
user447274's user avatar
4 votes
2 answers
545 views

how to check if the path from where the script is started stored on a hdd or ssd drive?

how to check if the path from where the script is started stored on a hdd or ssd drive? i have read that cat /sys/block/sda/queue/rotational show 0 for ssd and 1 for hdd. if [ "$(</sys/block/...
user447274's user avatar
1 vote
1 answer
110 views

add a randomize option in a bash script

in a bash script i do run this: seq 1 $(<howmany.txt) | xargs -I% -n1 -P$(<parallel.txt) mycommand --infile file% --option A --outfile file%.new it works. the values in howmany.txt and parallel....
user447274's user avatar
0 votes
1 answer
64 views

How to exit a shell if the subshell exit with an error [closed]

there is a script, 1.sh. 1.sh starts 1a.sh and then 1b.sh. But how to exit all scripts, how to exit 1.sh and how to not start 1b.sh if 1a.sh breaks with an error?
user447274's user avatar
0 votes
1 answer
121 views

Difference between -v, -z and -n while comparing variables in a shell script

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
  • 80
0 votes
5 answers
228 views

Convert Date Format %Y%m%d%H%M%S to unix epoch format

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
3 votes
1 answer
525 views

Strange variable scope behavior when calling function recursivly

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

15 30 50 per page
1
2 3 4 5
33