Questions tagged [shell]

The shell is Unix's command-line interface. You can type commands in a shell interactively, or write scripts to automate tasks. Use this tag for questions applying to /bin/sh and most compatible shells (ash, bash, ksh, zsh, …). For shell scripts with errors, please check them in http://shellcheck.net before posting here.

Filter by
Sorted by
Tagged with
-2 votes
1 answer
92 views

grep to find an exact word match with a period in it

I have a huge .csv file in this format: "acc","lineage" "MT993865","B.1.509" "MW483477","B.1.402" "MW517757","B.1.2" &...
user avatar
0 votes
1 answer
51 views

Can one pipe compound commands?

My question is: can/how does one pipe compound commands ({ list; })? See Exhibit B. Exhibit A given for comparison's sake. Exhibit A: $ cat << EOF | xargs -n 1 echo foo bar qux EOF ...
user avatar
  • 481
0 votes
2 answers
41 views

Every new loop has a different parameter value

This is for webp using cwebp and I'm testing all different possible qualities, given: cwebp -q 75 file.jpeg -o file.webp I want a loop like: for i in {1..4}; do cwebp -q ?? file.jpeg -o file.webp; ...
user avatar
-1 votes
3 answers
36 views

How to strip characters by argument?

I want to filter any comma and any double quote mark from output by some command with. For some entries. Pseudocode: removechar --any -, -" Current output could look like any of these lorem, ...
user avatar
  • 115
0 votes
2 answers
128 views

How to use awk $1 $2 in bash shell?

cat << EOF > test.sh cat $FILEA $FILEB | sort -k1,1 -k2,2n | mergeBed -i - | awk -F\\t '{print $1 "\t" NR "\t\t" $2 "\t" $3 "\t\t.\t\t" NR}' > ...
user avatar
0 votes
0 answers
42 views

I read "Advantages of using set -o vi" and have a question about same

Followup-up on Advantages of using set -o vi I'm learning vi and know nothing about emacs. I also type poorly and frequently need to edit my commands in the terminal. The idea of using vi to edit my ...
user avatar
  • 1
0 votes
3 answers
114 views

Paths as bash aliases only work in parent directories?

Can bash aliases be paths? Hi and sorry in advance for the noob question. I noticed a strange behavior when using bash aliases. My goal is to use short bash aliases for often used paths, to make ...
user avatar
1 vote
2 answers
115 views

Can someone tell me the difference between these three command substitutions?

I am asking why these three commands give three different answers: $ printf "%s\n" `echo ../.. | sed 's/[.]/\\&/g'` &&/&& $ printf "%s\n" $(echo ../.. | sed '...
user avatar
  • 13
2 votes
0 answers
52 views

bash: writing to the file descriptor #3 of an unnamed (anonymous) pipe

I need to call a PHP interpreter, which is in a docker container, from my Linux host system. For some reasons I don't want to install PHP on the host system. Now I'm trying to call PHP in this way: ...
user avatar
-6 votes
1 answer
63 views

Is there an example for a shell or computing accessibility culture aspiring a shell with more special characters and if so what is it? [closed]

I was always a bit frustrated from the lack of characters in modern computer systems such as, from what I know: A global template literal character for which the closest character today is a backtick ...
user avatar
  • 115
1 vote
1 answer
564 views

Grep a list of strings [closed]

I have a multiple strings that I want to find them in a list of files that are in a same folder. So, I want to put all the strings in a sort of list and then apply the command: grep -l string *,so I ...
user avatar
0 votes
0 answers
48 views

-sh: ./bin.bin: not found

https://developer.android.com/studio/releases/platform-tools#downloads I'm trying to run adb (link above) from my TinyCore Box, is a bare linux system running on busybox as user land. Anyways, issue ...
user avatar
  • 143
0 votes
1 answer
24 views

Issues creating boot and shutdown systemd daemon

I'm trying to create a config file for my unit but when I start the daemon after enabling and shutdown the computer it doesnt works. The script only executes the ExecStart line after network.target on ...
user avatar
  • 48
-4 votes
2 answers
1k views

I'm unable to install Firefox in WSL [closed]

$ sudo apt install firefox Reading package lists... Done Building dependency tree Reading state information... Done E: Unable to locate package firefox
user avatar
0 votes
1 answer
63 views

Piping the results from an SSH command to be saved locally [duplicate]

I've the following command in a script that I want to run that will happily output the result of all the remote commands to STDOUT on the console. ssh -t my-server1.my-domain.net << EOF ./...
user avatar
14 votes
7 answers
2k views

Copy & paste cleanly into a command like grep, without terminal echo cluttering the output?

I have some test output, looking like PASS: tests/test_mutex_rmw PASS: tests/test_mutex_trylock PASS: tests/test_malloc_irreg FAIL: tests/ARMCI_PutS_latency FAIL: tests/ARMCI_AccS_latency PASS: tests/...
user avatar
  • 488
0 votes
0 answers
23 views

Switching between two output cards

Okay so I'm trying to get to the point where I can have my speakers and my headset plugged in, and easily switch between the two whenever I need to huddle on slack. However its not proving easy. I ...
user avatar
  • 179
-1 votes
1 answer
42 views

write bash code loop a file line by line that have values, first word as a row and create csv [closed]

i have this sample data dn; uid=456456456,cn=users,dc=efsfb,dc=org,dc=co; objectclass; top; objectclass; person; objectclass; organizationalPerson; objectclass; inetOrgPerson; uid; 456456456; ...
user avatar
  • 101
0 votes
1 answer
114 views

How do I find the PID of a specific shell script that is sleeping?

I understand I can use pgrep -fl example.sh to find the PID of the script example.sh, but this doesn't work if example.sh is something like the following: (while true; do sleep 5 done) & ...
user avatar
  • 101
-1 votes
1 answer
265 views

How can I delete a file with spaces and quotes in the name?

How do I delete a file named 1 '2 3' 4 5 in Linux? None of the methods I've used have worked.
user avatar
  • 15
0 votes
0 answers
51 views

The two SSDs have the same name by-id

There is a single-disk ZFS pool. Now I want to add another ssd to the pool and create a mirror. zpool pool: datapool state: ONLINE scan: scrub repaired 0B in 00:00:03 with 0 errors on Sun Feb 13 ...
user avatar
  • 1
0 votes
1 answer
34 views

Unable to use custom git commands on Mac

I created a script like shown here to simplify clearing out my git remotes. Created the file with the format git-{command} and made it executable. Included file in PATH. The script seems to work if ...
user avatar
  • 3
-1 votes
3 answers
62 views

How to use cut to trim the first x variable spaces [closed]

I have a file that is like this: 67 lol 143 hi 21 test 1 ciao 5 lo I want to remove the spaces. 67 lol 143 hi 21 test 1 ciao 5 ...
user avatar
  • 221
0 votes
3 answers
125 views

How do I set an environment variables file on the command line?

I have a file .env.local that contains a set of environment variables that should be loaded when launching my shell script, is there a way to specify this file in the command line ? .env.local ...
user avatar
-1 votes
1 answer
75 views

dynamic variable name in shell script

I am deploying my shell script to a CI pipeline, there are three different environment variables defined on CI: $prod, $dev, $test. My script managed to return the correct string value based on ...
user avatar
-1 votes
1 answer
49 views

conditionally assign value to variable doesn't work

I am new in shell scripting. I have written a simple script to assign variable conditionally: #!/bin/sh my_env=$1 if (my_env=="dev"); then MY_TYPE="dev type" elif (my_env==&...
user avatar
0 votes
0 answers
12 views

How to expand regex from lines in a file similar to echo on command line? [duplicate]

I have a list of strings in a text file. The strings have regular expression ranges/lists in them. I want to be able to expand all the possibilities. It works if I select a string and paste it after ...
user avatar
  • 1
0 votes
0 answers
110 views

bash setuid, to drop root privileges, without execing another program [duplicate]

I have a bash script, I don't want to run another script. I just want to continue running this one, but as an unprivileged user. I was hoping for a builtin that will do the syscalls setuid(getuid()) ...
user avatar
1 vote
0 answers
25 views

If mv is in command, do not ask to correct name of file (in zsh)

When using zsh, if I'm renaming a file, the shell sometimes assumes I've made a typo in the filename and suggests another. Is there any way disable this specifically for the mv command?
user avatar
  • 283
0 votes
1 answer
73 views

How do I login as the root user?

I installed Debian a day ago and I'm very new to Linux please forgive me if I miss something obvious but: whenever I use sudo command it asks me for the current user password but the current user ...
user avatar
1 vote
2 answers
379 views

What is the difference between `ash` and `sh` shell on Linux?

I am new to a lot of tools on Linux. A quick search did not help, I only got more about bash or sh, and searching for it somehow leans towards bash in the search results. There are quite a few ...
user avatar
2 votes
0 answers
47 views

How to figure out why `bash simple_script.sh` works but `bash < simple_script.sh` doesn't?

I have a very simple script, simple_script.sh, consisting the following three lines bpeek 123450 bpeek 123451 bpeek 123452 If I run $ bash simple_script.sh all three bpeek commands in simple_script....
user avatar
  • 13k
4 votes
2 answers
340 views

loop through current directory store directory and subdirectory name in a array without duplicates

I have a scenario where I am looping through all directories and subdirectories in a given path; if a file with specific extension (.txt) is found, store the name of the directories and subdirectories ...
user avatar
  • 85
0 votes
0 answers
390 views

What this error message mean please: Ignoring request to auto-attach. It is disabled for org "15824072" because of the content access mode setting

When trying to subscribe my centos 8 to a redhat repos, I got the error bellow. Can someone explains what do I need to do ? [root@thiecentos8 ~]# subscription-manager attach --auto Ignoring request ...
user avatar
0 votes
1 answer
40 views

Remove Need For Carriage Return When Capturing output/errors to Log

I have the following code. I am attempting to capture both output and errors to log file and console. When the code is ran, it shows the usage but then pauses for a carriage return. Not a big deal ...
user avatar
  • 11
0 votes
0 answers
59 views

debian root commands not working on desktop environment

I have a debian box, and after some version update or so, root commands are not recognized while being in the desktop environment; for instance dhclient or reboot. At first, I took it as an additional ...
user avatar
0 votes
0 answers
34 views

Disable Bash completion for a single environmental variable

Suppose I have an environmental variable $SAVE_DIR=/etc/ used to return to a saved directory (here /etc/) from any Bash shell. Typing cd $SAV[Tab] expands to cd $SAVE_DIR which is quite convenient. ...
user avatar
  • 101
6 votes
2 answers
198 views

Is `dpkg --contents` unable to handle SIGPIPE?

I noticed a weird antipattern in some CI scripts I've taken over, which basically boils down to this code checking whether a particular file is present in a package: dpkg --contents some.deb > ...
user avatar
  • 47.2k
0 votes
0 answers
81 views

Git tab completion doesn't always work in zsh

Typing git TAB prints completion candidates, but typing git add TAB does not. This works in Bash though. The _git completion function is installed and loaded by zsh: usr/share/zsh/functions/Completion/...
user avatar
0 votes
1 answer
56 views

How do I use bash style $() syntax with the posix shell?

I have this base command: SOME_VAR='blabhablhaba' bash -c "$(curl -L https://run_script.sh)" How do I do this with the posix shell? This fails: SOME_VAR='blabhablhaba' sh -c "$(curl -L ...
user avatar
0 votes
0 answers
25 views

If I complement the address, I have the previous command append in sed

I have this file: $ cat ciao ciao ciao ciii ciaooo ocisdjoo kdvkks kdafjdjf akfk and $ sed ciao -n -e "1,3p" ciao ciao ciii $ sed ciao -n -e "1,3!p" sed ciao -n -e "1,3ps -...
user avatar
  • 221
3 votes
2 answers
283 views

Compare files across servers

Once upon a time I remember doing something roughly like this: vimdiff <(scp://some_server/home/user/.zshrc) <(scp://some_server-qa/home/user/.zshrc) (where some_server and some_server-qa are ...
user avatar
  • 8,475
1 vote
2 answers
61 views

Copying 10 consecutively numbered files

I have a file structure which looks like this: Project | +-- video_1 | | | +-- video_1_cropped | | | +--frame_00000.jpg | +--frame_00001.jpg | +... | +—-...
user avatar
0 votes
0 answers
40 views

Integrate a 'suspend' shell command into a Python script or not?

I run a Python script from a shell script because I suspend the system after the Python script is finished with this shell command : [ -t 0 ] || systemctl suspend The shell script is run as a ...
user avatar
  • 29
0 votes
1 answer
22 views

Unable to read and send the output of the count of table through email

Tried to figure out but could not find much help. I want to capture the count of the table and send an email if the count is more than 0. The output in the email should be as shown below only if it ...
user avatar
  • 3
0 votes
1 answer
105 views

fd --exclude all except dir1 dir2

fd searches files and directories, and can be called with except or prune as an option to limit the results. Is there a way to search only for specified directories? I want to use fd, in fzf, and have ...
user avatar
0 votes
0 answers
67 views

How can I print grep results using curl in a shell script?

How can I print grep results in a shell script? This is my code: #url is https://batteryzone.pk/assets/kcfinder/browse.php read -p "Url: " url response=$(curl -Lsk $url | grep uploadURL) if [...
user avatar
1 vote
1 answer
252 views

pass long html string as argument to bash script (Filename too long)

I am passing an html string as an input to a bash script: Script.py def bash(commandStr): subprocess.Popen(commandStr, shell=True, executable="/bin/bash") def sendmail(subject, to, ...
user avatar
0 votes
1 answer
54 views

Using a variable with a path name with a space to construct a new command variable without breaking the final command?

I've read a bunch of other questions about shell quoting and spaces in file names, and the suggestions don't seem to be working in this case. Putting a variable with a string with an escaped space ...
user avatar
  • 1,011
0 votes
3 answers
156 views

Using numbers with decimal points in if statements and operators

I'm trying to write a script that detects the Linux OS and version and through the use of conditions and operators execute different commands depending on the result. Detect OS if [ -f /etc/os-release ...
user avatar

1
3 4
5
6 7
228