Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [sh]

sh stands for a shell. It is also often used as extension for a shell script.

0
votes
0answers
34 views

How to run a command when any process starts?

I have an sh script to update my wallpaper which uses pscircle in order to display running processes. The script runs every five seconds to update the wallpaper, but I would like it so that the script ...
0
votes
1answer
66 views

How can I use a “here document” in the middle of a pipe?

I am wanting to generate some content using a heredoc as a template: passphrase=$(<passphrase) envsubst <<EOF apiVersion: v1 kind: Secret metadata: name: openshift-passphrase stringData: ...
1
vote
1answer
81 views

Bad number error with Linux float variable value comparison operator condition

I'm trying to test some logic on an Antminer S9 where I get the output of a command and then from that output I grab a specific float value so I can then put this value into a variable and process ...
2
votes
2answers
109 views

Find filenames with uppercase extension

How can I find all the files with their extension in uppercase in recursively in a directory. I've tried : $ find -name "*.[A-Z][A-Z][A-Z]" Seems to work but of course this does not check files ...
1
vote
2answers
74 views

Is it POSIX-compliant to use a shell function in a pipeline?

Is it possible to use a shell function in a pipeline? Say I had a function that acted like grep, called mygrep. Is there any way, using only POSIX shell features, to be able to invoke mygrep like ...
0
votes
0answers
42 views

Audio Issues With FFmpeg Script

I have a script to convert all files in a dir using ffmpeg. When I convert a file, it has audio distortion. If I convert the same file using something like handbreak there are no issue. Any ideas what ...
30
votes
2answers
4k views

What is wrong with “echo $(stuff)” or “echo `stuff`”?

I used one of the following echo $(stuff) echo `stuff` (where stuff is e.g. pwd or date or something more complicated). Then I was told this syntax is wrong, a bad practice, non-elegant, excessive, ...
2
votes
1answer
101 views

Grep regex result not as expected?

Using FreeBSD 11.1: #!/bin/sh if printf 'abcde.fgh' | grep -iEq '^[^][$^*_-]'; then echo "test 1 success" else echo "test 1 fail" fi echo if printf 'abcde.fgh' | grep -iEq '^[^][.$^*_-]'; ...
0
votes
1answer
61 views

Raspberry Pi headless, my if [[ file1 -nt file 2 ]] that thinks the two files have the same modified date

So I have a player script "player.sh" and an updater script "updater.sh". player.sh plays any mp3 file in /home/filepath/ using a wild card *.mp3, this works as expected. what I want is for the ...
79
votes
1answer
6k views

Is redirection with `>>` equivalent to `>` when target file doesn't yet exist?

Consider a shell like Bash or sh. The basic difference between > and >> manifests itself in a case when the target file exists: > truncates the file to zero size, then writes; >> ...
0
votes
0answers
164 views

SSH : “Connection reset” for one of my LXC's

I've been stuck for a while about my ssh connection to one of my LXC's. Indeed, when I connect in ssh to my other LXC, everything works. However, one does not want to connect and displays this error: ...
0
votes
1answer
40 views

Bash modifying text between marked lines

I have a file with more than 8000 rows. File is divided into sections, each section is labeled with text like ##C, ##T,##N. I have to modify some rows in the file. I used command SED to mark lines ...
0
votes
3answers
196 views

Quit loop if a key is pressed

I want to exit the script if any key is pressed. #!/bin/sh while true; do df -h | head sleep 10 clear done Any suggestion?
1
vote
2answers
175 views

Get intermediate nodes using ping

I need to get intermediate nodes when requesting the route through ping. I can get the intermediate routes through traceroute url, but in the server there's a problem I cannot use traceroute. I ...
0
votes
1answer
434 views

using xargs pass arguments to sub shell with pipe

I want to rename a number of files. I think I can use xargs to do it. find ./ -name "upload.log-*" ./upload.log-20180622.gz-20180624.gz-20180626.gz ./upload.log-20180624.gz-20180626.gz ./upload.log-...

15 30 50 per page