Skip to main content

All Questions

Tagged with
Filter by
Sorted by
Tagged with
0 votes
1 answer
29 views

SOX do not want name files

Want to record a radio broadcast into separated files. receiver | sox -traw -r8k -es -b16 -c1 - -b16 -es -c1 -r48000 -t wav ~/myfolder/$(date +%H_%M_%S).wav silence 1 0.10 0.1% 1 1 0.1% : newfile : ...
Oleg M's user avatar
  • 3
0 votes
1 answer
41 views

Match a User That Starts With a Single Letter

I've been handed a script written by another and been asked to modify it according to their needs. There's one line that needs to be altered: if [ "$user" == "nobody" ] This ...
user2090974's user avatar
0 votes
3 answers
39 views

Why doesn't `bash` work with piped output, when the output is as expected?

I'm running the following command to alias an entire folder of scripts: ls | grep '\.sh$' | sed 's/\.sh$//' | awk '{print "alias "$1"=\"./"$0".sh\""}' | xargs -...
Maxime Franchot's user avatar
2 votes
1 answer
117 views

Execute self-extracting bash script (with binary data appended) w/o saving it first

I have a self-extracting bash script (binary data appended to the end) like this: #!/bin/bash export TMPDIR=$(mktemp -d) ARCHIVE_START_LINE=$(...) # <omitted> # extracting data archive into a ...
Edward Ruchevits's user avatar
1 vote
1 answer
34 views

Moving directories that names end in - number matching a list.txt file

Graphic of Folder Structure : I am very new to advanced shell commands and scripting. I have fundamental terminal knowledge but have never attempted to create an automation like this before. A pure ...
Roco Gman's user avatar
1 vote
0 answers
89 views

MPV to play videos with a geometry

I have YOCTO build and I have integrated the mpv to the image. I need to test something so, I wrote a script that could play videos with a certain width and height and position on the screen but mpv ...
thehilmisu's user avatar
0 votes
2 answers
233 views

Bash provide comma-separated list in multiple lines

I have a bash script that is suppose to run another program called file-selector. #!/bin/bash ... ./file-selector -exclude="a/b/c/d/e/f1,a/b/c/d/e/f2,a/b/c/d/e/f3,a/b/c/d/e/f4,a/b/c/d/e/f5,a/b/c/...
Subzero123's user avatar
1 vote
1 answer
59 views

merge numbered files from different directories into same directory in correct order

I have some directories named FOO and BAR and etc. that have files in form FOO/ 1.png ... 18.png BAR/ 1.jpg ... 12.jpg ... and I would like them to be all copied into the DESTINATION directory ...
user3446323672's user avatar
0 votes
1 answer
78 views

The last command output in linux for reboot is not giving the uptime instead it says still running twice

[root@localhost test]# last -x reboot -s -30days reboot system boot 5.14.0-325.el9.x Sun Mar 10 10:51 still running reboot system boot 5.14.0-325.el9.x Tue Mar 5 03:05 still running In the ...
AshKash's user avatar
0 votes
1 answer
34 views

shell helper function wrapping `find` and ignoring some dirs

I have a bunch of scripts which follow the pattern of: find files which match a pattern do something The problem is that there are several "hazard" directories which are large and slow, ...
Tim Hockin's user avatar
3 votes
3 answers
652 views

Bash [[ test =~ regex ]] vs perl command result

Is the bash operator =~ equivalent to a perl invocation? filename="test-33.csv" regex="([^.]+)(-\d{1,5})(\.csv)" With bash test: if [[ "$filename" =~ $regex ]]; then ...
rellampec's user avatar
  • 133
0 votes
1 answer
151 views

How to convert code from test format to if fi format?

I have code that opens a bash file in a terminal for entering the sudo password: test "$IN_TERM" || { export IN_TERM=1 konsole -e "$0" exit 0 } && true I need ...
moninah's user avatar
  • 35
0 votes
1 answer
245 views

Reboot in middle of bash script

I'm writing a bash script to setup some services in Ubuntu. I require some system reboots between some steps. The problem with this is running reboot interrupts the script as well. Is there a way for ...
Voldemort's Wrath's user avatar
2 votes
0 answers
260 views

How can I close a browser window from a bash script?

I would like to open and close windows from a bash script but in my two versions of the code it gets stuck when it opens the first window and does not close the current window and then open the new ...
Bambino 's user avatar
0 votes
1 answer
89 views

How deep is too deep for Nested Folders in a Bash program?

I am somewhat new to Bash and am writing a program to install .NET SDK and Runtime on each of the available Linux distros. The problem I am having is that I am trying to source functions from two ...
sonAndrew's user avatar
  • 101
0 votes
0 answers
48 views

How to combine 2 rsync outputs into 1 command?

using: neofetch --stdout |grep 'OS:' OS: Kubuntu 22.04.3 LTS x86_64 Shell: bash 5.1.16 rsync --version rsync version 3.2.7 protocol version 31 variables, SourceDisK1 src1 and destination ...
joseph22's user avatar
  • 367
-1 votes
1 answer
2k views

Echo all the output from a ls command

I have the follow files in my folder: a.jpg b.jpg c.jpg And I have the follow script: #!/bin/bash echo $1 If I run: script.sh $(ls) My output is: a.jpg But I want to be: a.jpg b.jpg c.jpg So, Why ...
Magenta's user avatar
  • 11
0 votes
1 answer
62 views

Complex find statement

Have a script that I use to purge old backup directories. All the directories are named YYYY-MM-DD. The backup directories have links in them as the backups are incremental using the rsync --link-dest....
Jeremy's user avatar
  • 1
0 votes
1 answer
63 views

rm not removing directory

Having a strange issue. Using a script to go through our backup folders and delete any folder not named like the 1st of the month (2023-05-01) and older than 60 days. It works in the sense that it is ...
Jeremy's user avatar
  • 1
0 votes
2 answers
437 views

Bash printf: what does format specifier %P mean?

The printf statement : find directory1 -type d -printf "%P\n" | sort > file1 in the answer https://superuser.com/a/166322/856910 includes a format specifier %P. From the output of this ...
Leo's user avatar
  • 3
1 vote
0 answers
340 views

Sed editing of large text file much faster than native bash substring replacement?

I have a ~19MB text file which I would like to perform many find/replace operations on. I originally wrote the script to loop over inplace sed operations e.g. sed -i "s|$pattern|$replacement|g&...
Neuromancer's user avatar
1 vote
0 answers
132 views

Running a bash script that calls R from within i3 does not work, but running it directly from the terminal works. Not sure if issue is i3 or not

I have a bash script that calls on R, and is mapped to a keyboard shortcut in my i3 config, like this: bindsym $mod+q exec --no-startup-id test-r-not-working-from-within.sh Here is a simple example ...
emilBeBri's user avatar
  • 121
2 votes
1 answer
859 views

List only bottom level directories using find

So, let's say I use find to search a directory for folders. find "/home/user/Documents" -type d -print While this does list all the directories in said location, I only want to get the ...
Eduardo Perez's user avatar
1 vote
1 answer
297 views

Can't input text in Bash function called with key binding

I have added a simple function to my .bashrc file and bound it to a key combination using the bind command. The function prompts the user for input using read, like this: myscript() { read -p &...
Scooby-Doo's user avatar
0 votes
1 answer
137 views

Glob expression as an argument can not be printed

I am trying to write a simple bash script which would print the argument provided as an input to the terminal. echo "${1-nothing}" I have tried using $@ or without quotes. If I enter * as ...
Kay's user avatar
  • 1
1 vote
1 answer
827 views

Can I and how to use `script` in a bash script

This must be the most frustrating research I've ever attempted (so far). So, there is script(1). I've been trying to add it to the start of a bash script I have (I was looking for a way to log every ...
João Ciocca's user avatar
0 votes
1 answer
102 views

Ubuntu - Deleted service still working

I created an .sh file for my remote laptop that would play an alarm file through ffplay and send me a telegram message whenever the power plug got disconnected. The file worked great when I ran it in ...
qwerty's user avatar
  • 11
2 votes
1 answer
1k views

How to take file name from yt-dlp and use it as ffmpeg output file name?

I'm trying to get the output name to be the same as the input name while using the pipe command in ffmpeg. Example: The file is called 1-Minute Audio Test for Stereo Speakers & Headphones [...
Rick T's user avatar
  • 153
1 vote
1 answer
2k views

"read" not working if called inside bash while loop

Why the read function inside this while loop not working? if i uncomment echo (and comment read) it prints several times, but if the "read" is uncommented it just exits function. Same "...
Nasir's user avatar
  • 135
1 vote
0 answers
299 views

How to generate help/usage description from getopt?

Is there a way to generate the "help" or "usage" message of a command from getopt? Something like this: ARGUMENTS=$(getopt ... -- "$@") echo $(help "$ARGUMENTS")...
Eduardo Ito's user avatar
0 votes
1 answer
43 views

Assign to variable in BashScript

This command gets all the users from the logs. It works great grep $srcIP $cFilename | grep "Username: " | awk -F"Username: " '{print $2}'| awk -F"," '{print $1}' | ...
user1736786's user avatar
-1 votes
1 answer
131 views

how to use 'sed' in bash to delete a line from a specfic point on?

so i have these lines for example: name,lastname,[email protected] name2,lastname2,[email protected] i need to delete the '[email protected]' in every line essentially i want to make sed do "delete ...
imshad shadshad's user avatar
0 votes
2 answers
210 views

Highlight filename in "find" command

I have this command which works great find . -type f -name *.txt -exec grep -li blah {} \; Let's say the output will be: /tmp/folder1/file1.txt /tmp/folder2/myfile.txt /tmp/thisfile.txt If I was to ...
user1736786's user avatar
0 votes
1 answer
88 views

FFMPEG MultiPlex all video's to all audio's

(windows 10 64) I have seen & read MULTIPLE (50+) answers to forms of this question but not for what Im trying to do. I have a folder with 30+ short clips (few seconds each) mp4's I also have a ...
PHaRTnONu's user avatar
1 vote
1 answer
983 views

Reload user's group in a script

I'd like to create a new group in a script, assign the current user to it, reload the user's groups and continue executing commands that require the new group. In this related question I found nice ...
Felix's user avatar
  • 211
0 votes
1 answer
65 views

What are the diffferences between my bash while loops? [closed]

File: cat csvfile apple,1 orange,2 banana,3 Code: head -2 csvfile | while read line do f1=$(echo $line | cut -d ',' -f1) f2=$(echo $line | cut -d ',' -f2) echo "$f1 -> ...
genx1mx6's user avatar
  • 103
1 vote
1 answer
2k views

Read from stdin while piping to next command?

How can you prompt a user for input, when the output is being piped? > (echo -n 'input data: '; read TEST; export TEST) | echo "done: ${TEST}" This does not show the "input data&...
Josh M.'s user avatar
  • 1,518
2 votes
1 answer
1k views

Execute EOF command remotely in one line

I am facing a problem. If I execute this command, it works normally, but I need to execute it using SSH connection. Is there a way to do it in just one line of command? Thank you for your attention. ...
Antonio Costa's user avatar
0 votes
1 answer
150 views

Can I indent pv's output (or of any command that outputs CRs)?

With pv, I can show a progress bar for anything I pipe through it, for example echo 1234567890 | pv --size 10 >/dev/null It prints a nice progress bar that gets updated whenever more data comes ...
Bowi's user avatar
  • 1,527
1 vote
1 answer
183 views

Only print terminal directories in "du"?

Is there a generalized solution for getting only the deepest directories? Counting slash characters won't work, because if I change to --max-depth=4, the deepest directories won't all have the same ...
RonJohn's user avatar
  • 261
0 votes
1 answer
184 views

shell script getopts options validations

I'm trying to check if all the validations are true and work but my logic I think is not correct and I'm new to coding. So I initialized p=0 and un=0, when user passes both option it should give error....
brucelee's user avatar
0 votes
1 answer
241 views

Remove duplicate multiline patterns in bash

I have this text file in which I would want to remove multi-line duplicates. In this case, the interface e0/0 block is repeated in the file, and I would like only a single instance of these lines ...
john jr.'s user avatar
1 vote
0 answers
339 views

Script to automatically set up my workspaces configuration upon login (Linux Mint 20.1)

I am using Linux Mint 20.1 at the moment. My main work involves writing bash scripts for system monitoring. I am still new in this so I am learning on the job as we go. Typically, upon logging in to ...
Chris Quek's user avatar
0 votes
0 answers
147 views

different arguments to bash

what is the usage of -ec in bash command on terminal when I write bash -ec I get an error : bash: -c: option requires an argument
dev's user avatar
  • 111
2 votes
3 answers
4k views

Linux script to run systemctl --user commands with a specific user

I'm creating a bash script where I try to install a program as a user service but I'm unable to run systemctl --user commands within the script. This is what I have: #!/bin/bash (...) useradd -M -g ...
bggoxp's user avatar
  • 41
0 votes
1 answer
55 views

[[ -v var ]] behaves differently inside bash script vs CLI

I want a bash script that will set several environment variables (userid, password, token) to some default values if they don't already exist. The existence test works on the CLI but not in the ...
Magilla's user avatar
0 votes
1 answer
73 views

Variables in Bash scripts

I am attempting to create a script that shows how much memory every user on the system is using in their home directory. Everything was going smooth till I started using the du -sh command to start ...
Cody Syring's user avatar
1 vote
0 answers
54 views

Unexpected behaviour in bash function

I'm scratching my head why a bash script won't work. I've condensed it to the following: #! /bin/bash function syncuser() { cat ~nagios/.ssh/authorized_keys cat /home/$1/.ssh/...
davidgo's user avatar
  • 71.3k
0 votes
1 answer
4k views

Making a bash script execute ssh

I want a bash script to start multiple SSH connections to multiple linux servers in multiple new bash windows, not for further processing, just to connect with a simple command instead of having to ...
Caeleste's user avatar
  • 831
0 votes
1 answer
313 views

how to call bash function on login as root user

I'm using Arch (with Xfce) and need to run a bash function when I log in to my OS. The function that I wrote, needs to be run by root access. This is the function: my_func() { sudo -v sudo chown ...
qafoori's user avatar
  • 101

1
2 3 4 5
12