Skip to main content

All Questions

Tagged with
-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 ...
user447274's user avatar
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{...
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
-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
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 } &...
balupton's user avatar
  • 634
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 ...
saeedgnu's user avatar
  • 153
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 ...
Enlico's user avatar
  • 2,179
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 /...
Fravadona's user avatar
  • 1,581
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 ( ...
yael's user avatar
  • 13.9k
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 "...
Qiu Yangfan's user avatar
-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-...
MohammadReza Arefi's user avatar
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 ...
Shamir Husain's user avatar
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 ....
Fravadona's user avatar
  • 1,581
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 ...
Astora's user avatar
  • 499
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=...
lewisxy's user avatar
  • 171

15 30 50 per page
1
2 3 4 5
192