All Questions
2,876 questions
-2
votes
0
answers
48
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
84
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
...
7
votes
1
answer
1k
views
Why does MacOS always append to a redirected file descriptor even when told to overwrite? Ubuntu only appends when strictly told to append
Given the following code:
out="$(mktemp)"
rm -f "$out"
clear
printf '%s\n' 0 >"$out"
{
printf '%s\n' '1' >/dev/stdout
printf '%s\n' '2' >/dev/stdout
} &...
0
votes
1
answer
45
views
cpulimit: detect failure / exit status in Linux
I'm using cpulimit in a Bash script to run a certain command (ffmpeg) with a limited CPU usage, but I want to know if the command fails. But when the command(ffmpeg) fails with any error, cpulimit ...
4
votes
1
answer
63
views
What are the rules that determine file permissions of b after I do cp /path/to/a /p/t/b, depending on file permissions of /path/to/a and all dirs?
In Classic Shell Scripting from O'Reilly, Arnold Robbins and Nelson H.F. Beebe write the follwing example:
$ umask
023
$ rm -f foo
$ cp /bin/pwd foo
$ ls -l /bin/pwd foo
-rwxr-xr-x 1 root root ...
4
votes
1
answer
338
views
Restore deleted bytes after a `wipefs` on Linux
After re-installing a Linux machine, I inadvertently ran wipefs -a on the installer pendrive:
$ wipefs -a /dev/sd?
/dev/sda: 8 bytes were erased at offset 0x00010040 (btrfs): 5f 42 48 52 66 53 5f 4d
/...
0
votes
1
answer
62
views
changed ownership on folders by user that defined in sudoers file
I have the following simple script that changed ownership on folders
more hola_config.sh
#!/bin/bash
chown -R hola:pola /home/darna
chmod -R 775 /home/darna
in /etc/sudoers I added the following ( ...
3
votes
3
answers
183
views
How to quit from a pipeline "command1 | command2" while keeping a background subprocess launched by command1 alive?
Regarding the command cmd1.sh | grep "message", in which cmd1.sh is as below
#!/bin/bash
echo "message from foreground father proess$(date)"
setsid sleep 100 &
echo "...
-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 ...
7
votes
4
answers
1k
views
Ways to keep files in /tmp?
I have a RHEL 8 workstation that hosts an app whose GUI is accessible through https on an unprivileged port.
When the app is started, it creates a few socket files in /tmp with random names and the ....
1
vote
2
answers
140
views
How to sum all disk size in Linux?
We have some Linux servers with several disks.
[root@xxxxx~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 ...
6
votes
1
answer
749
views
bash pipe loses data when command crashed
Consider this simple program (abort.py) that writes some text to stdout and stderr and then crashed (abort()).
import os
import sys
print("end stdout")
print("end stderr", file=...