All Questions
724 questions
-2
votes
0
answers
36
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 ...
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{...
-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 ...
-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
...
-1
votes
1
answer
118
views
zip every month files and delete them [closed]
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-...
0
votes
4
answers
120
views
Clean up bash script
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 ...
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
...
-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] (...
0
votes
0
answers
46
views
How to only suppress warning outputs from cryptsetup?
In Linux in Bash i run a script with some cryptsetup calls like
--luks2-metadata-size=16k --luks2-keyslots-size=256k .... luksFormat ....
that brings Warning outputs.
I know and understand, but i ...
0
votes
1
answer
73
views
Open 2 mate-terminal instances and run commands
I am trying to set up a script that runs 2 mate-terminal instances, each with a different command.
The script is set up as a cronjob.
The problem is, while the script works fine when executed manually,...
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....
0
votes
3
answers
103
views
how to process a sequence of items in groups of N at a time
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 ...
-2
votes
2
answers
456
views
runuser: execute commands without use of quotation marks?
Overview
I'm attempting to execute commands as a different user without using quotation marks as well as making sure the executed command isn't inheriting environment from the parent shell.
runuser ...
12
votes
2
answers
5k
views
Check if current user can run sudo without requiring a password
I want to check if the current user running a BASH shell script has access to passwordless sudo or not. If they don't, I'd rather have the script exit rather than prompting them for a password.
0
votes
0
answers
89
views
keep sudo effective without password after update sudo package itself
I want to write an automation script in Bash that requires frequent use of the sudo command. To avoid entering my password repeatedly after the sudo timeout, I've tried the following:
#!/bin/bash
sudo ...