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
0 votes
1 answer
56 views

Create user with shell access but no GUI login

I need to create a User that can interact with shell it has home directory but no GUI login. I have looked at many articles on this. but I am pretty confused as the correct process useradd --system ...
tonysar's user avatar
2 votes
1 answer
58 views

Linux (Bash): Are Login Scripts With Exit Conditions Or Exec Commands Possible?

I want to run a login script for all users, that checks whether the user is an administrator and, if so, offers the option of a host login, or launches a systemd-nspawn container by default - that way ...
Techsplorer's user avatar
1 vote
5 answers
135 views

How can I convert a reverse IP address to IP?

I want to convert a list of reverse DNS IP addresses to normal format. i.e. Convert 43.201.125.10.in-addr.arpa to 10.125.201.43 Is it feasible?
Wynford Thomas's user avatar
6 votes
2 answers
1k views

Why xargs does not process the last argument?

Observe: mark@L-R910LPKW:~$ echo a b | xargs -d' ' -I{} bash -c 'echo {} 1' a 1 b bash: line 2: 1: command not found mark@L-R910LPKW:~$ What is going on?
mark's user avatar
  • 387
-3 votes
1 answer
126 views

Im trying to run a shell script but I keep getting If: expression syntax. How to I get rid of it

Good afternoon, I'm trying to run my code for assignment 4 but I keep getting an expression syntax error, can you tell me why? #!/bin/sh if [ "$#" -ne 1 ] then echo "Usage: ...
Gbreezoo's user avatar
12 votes
2 answers
3k views

Does ssh run commands (rather than shell itself) in a login shell?

According to man sshd: LOGIN PROCESS When a user successfully logs in, sshd does the following: <...> 9. Runs user's shell or command. All commands are run under ...
Anthony's user avatar
  • 567
0 votes
1 answer
3k views

How to extract stdout of command as variable in ansible playbook

I am trying to install docker credential store with pass on a VM using Ansible here is the part of the credential store's code in the playbook.yaml However, the problem is I try to export the gpg key ...
devlooper's user avatar
2 votes
1 answer
34 views

How to concatenate files and give another name to output based on the match from another file?

I have a directory data in which there are several fastqs like below: SRR13456784_1.fastq SRR13456784_2.fastq SRR13456784_3.fastq SRR13456785_1.fastq SRR13456785_2.fastq SRR13456785_3.fastq ...
stack_learner's user avatar
1 vote
1 answer
64 views

Does POSIX sh require expanding $! in order to keep a reference to the child process?

Spec According to this online POSIX Spec, in Shell & Utilities, Shell Command Language, Section 2.9.3 Lists has the following to say about Asynchronous Lists: When an element of an asynchronous ...
D. Ben Knoble's user avatar
0 votes
1 answer
161 views

How to track all signal in 'trap'?

Can I test keyboard shortcuts and some kill commands with a script and know which signal is caught by trap?
Gilles Quénot's user avatar
0 votes
3 answers
95 views

Handle parentheses in this xargs multi-command

I suspect the following has been answered already but I don't know the terminology for the issue I'm having well enough to find an existing answer. I'm working on a command to go through a list of ...
SSilk's user avatar
  • 133
1 vote
1 answer
31 views

How to Check Numlock State of Virtual TTYs Without Elevated Privileges?

I am trying to get the numlock states of multiple virtual TTYs. But my normal user account doesn't have read permission for some of them. $ for tty in /dev/tty{1..6}; do setleds < ${tty} | grep &...
AntumDeluge's user avatar
0 votes
1 answer
46 views

ls -F/--classify marks every file as an executable

ls -F classifies ALL files on my mounted partitions as an executable (it appends an asterisk to the end of the file name). The same command performs correctly in other places like my home folder, so I ...
what the's user avatar
  • 113
0 votes
2 answers
88 views

How is output passed as input in pipes?

I am trying to understand how pipes | work; in particular, in what way the output from the left command is passed as the input to the right command. Is the output from the left command treated as a ...
Taha Ghassemi's user avatar
0 votes
4 answers
526 views

Shell script to list all files in a folder on a single line

I have this folder structure: /Brand/ProductCode01 /Brand/ProductCode02 Each ProductCode## folder contains many JPG files, like image01.jpg, image02.jpg and so on I need to create a file that ...
Cesare Rossi's user avatar
0 votes
0 answers
46 views

Compress list of files as their shortest exclusive glob

How can I convert a list of files to the minimum-length glob that expands to those files and no others? E.g. in a directory root ├── one └── two Then the list root/one:root/two can be converted to ...
theonlygusti's user avatar
0 votes
0 answers
30 views

'-bash: line 1: rescanscsi: command not found' error even though script location is in PATH and other script runs fine from same folder [duplicate]

I'm new to linux, trying to switch over from Windows, and I could really use some help. This is actually my first time using a forum such as this so please forgive any errors I make. I'm using Linux ...
TT Radykal's user avatar
-2 votes
1 answer
41 views

confusing concepts of environment variables, shell variables, shell function, userdefined var, command aliases [closed]

I am studying about environment in linux, and these words confuses me. isn't there just system defined variables generated by kernel and user defined variables which is assume to be lower case?? ...
user21657448's user avatar
0 votes
0 answers
300 views

Use shell command to set env variable in Dockerfile

I am trying ot set up a custom redis alpine image and I would like to set the private IP that get assigned to the instance as an environment variable. In order to do so, I am using the following ...
user20656733's user avatar
2 votes
2 answers
106 views

how to specify multiple inputs for a command in shell script

I have several fastq files per sample and all of them should be provided at once as an input (as they all belong to one sample, they should NOT be treated independently like in a for loop, as they are ...
Anna1364's user avatar
  • 1,016
0 votes
1 answer
51 views

Problem with bash builtin bind and escaping

I'm trying to add a history fuzzyfind hotkey to my bash shell. However, my intended command gets cut in the middle: [april@Capybara-2:~]$ cat ~/.bashrc bind "\"\C-r\": \"\$(...
AprilGrimoire's user avatar
1 vote
1 answer
68 views

Remove entire folder when grep find no files with a match inside the folder

I have thousands of folders with a single html file in each folder. I want to remove the entire folder if grep find no match to example.com in the html file. I know how to remove the non matching file....
xorghelpneed's user avatar
5 votes
2 answers
580 views

touch command not able to create file in write-permitted directory

This is my user $ id uid=1000(pzk) gid=1000(pzk) groups=1000(pzk) This is my directory structure $ ls -tlrh total 12K d-w--w--w- 2 root root 4.0K Apr 13 10:53 write-for-everyone dr--r--r-- 2 root ...
pzk's user avatar
  • 117
1 vote
0 answers
323 views

Merge set x (xtrace) and v (verbose)

How to merge set -x and set -v in ash? (or set -v with a prefix) In other words, echo back command upon running. The DEBUG signal does not exist in ash: DEBUG: invalid signal specification. set -x $ ...
wjwrpoyob's user avatar
  • 376
0 votes
0 answers
21 views

Insert into the shell a filepath used from a previous command [duplicate]

I have a series of commands like $ touch path/to/file.cc $ less path/to/file.cc ... and in the second command I'd like to automatically insert the path used in the previous command. Is there a way to ...
JeremyKun's user avatar
  • 314
0 votes
0 answers
84 views

Running a local script on remote server over ssh with sudo privileges

I have a script script.sh on local machine which I want to execute on remote server with sudo permissions. I am logging in to remote server through SSH and executing the script using the below command ...
Anubhav Rai's user avatar
0 votes
1 answer
75 views

What is the number inside the parenthesis on a Linux command? [duplicate]

What is 1? What is 3? What are the numbers called and is there a full list with explanations? $ whatis nvim nvim (1) - edit text $ whatis printf printf (3) - formatted output ...
Pixelbog's user avatar
  • 540
0 votes
0 answers
86 views

Midnight Commander: shell link connection not show dirs

Everything works fine when the target computer is windows 10 with cygwin and openssh 5.9p1-1 (libopenssl098 0.9.8t-1) [computer1]. After upgrading cygwin with openssh 1.1.1t-1 (libssl1.1 1.1.1t-1) [...
321Peto's user avatar
0 votes
0 answers
120 views

Limit the total CPU usage for the entire system?

I'm running a Chrome instance on a NAT VPS. Being a NAT VPS it has some restrictions such not not allowing a 15min average load greater than 1. However, just starting and going to a few webpages ...
DentFuse's user avatar
7 votes
1 answer
1k views

mv: rename <oldname> to <newname>/<oldname>: Invalid argument

On my TrueNAS (FreeBSD 13.1) server I have a directory named OldHDD which I want to rename, but I get an error: % mv OldHDD oldhdd mv: rename OldHDD to oldhdd/OldHDD: Invalid argument I have tried ...
J.Lewandowski's user avatar
3 votes
2 answers
693 views

Race condition not seen while two scripts write to a same file

I have two scripts running parallelly and they are echoing to the same file. One script is echoing +++++++++++++++ to the file while the other script is echoing =========== to the file. Below is the ...
Anubhav Rai's user avatar
6 votes
2 answers
806 views

bg command not sending process to background

After pausing the process with ctrl-z, I attempted to send it to background with bg command. Unfortunately, the process isn't sent to the background, and reappear to be running foreground. Then, I do ...
Faxopita's user avatar
  • 177
0 votes
1 answer
103 views

How was a shell like when operating systems didn't had a GUI? [closed]

I understand the concepts of terminal, console, shell and their differences. I know a shell today is an interpreter that communicates with the OS kernel to perform some actions and does it through ...
GerardoAGL96's user avatar
0 votes
0 answers
73 views

How to cp all files within /var/log without using sudo

This is in shell script. I want to create a directory copy of /var/log while preserving directory structure (so not tar). I do this by making a directory and using cp -R /var/log cpdir However, some ...
John Smith's user avatar
0 votes
0 answers
25 views

bash lost string begin if "-e" are first symbols [duplicate]

I need echo this construction and cannot use additional quotes #!/bin/bash set -x export jaz="-e test \ -e test2 \ -e test3 " echo $jaz result is tuy$ sh test.sh +...
tuytuy20's user avatar
1 vote
1 answer
87 views

zsh completion: complete --options for custom script

I have zsh completion rule for custom script. My script can take zero or more options (starting with -) and zero or more arbitrary strings (patterns): _arguments -S : \ '--foo' \ '--bar' \ ...
Martin Vegter's user avatar
2 votes
1 answer
196 views

How to parse positional parameters of Bash script when using "Bash Strict Mode"?

Bash Strict Mode is defined as follows: #!/bin/bash set -euo pipefail IFS=$'\n\t' http://redsymbol.net/articles/unofficial-bash-strict-mode/ Consider the following parsing of positional parameters in ...
Shuzheng's user avatar
  • 4,073
0 votes
2 answers
75 views

Linux - Live List of Running Processes

Is there a way to get a list of all running processes that will auto update when new processes start running or remove themselves if they have stopped running? Example: ps gives me a list of processes ...
Chicken Sandwich No Pickles's user avatar
0 votes
1 answer
266 views

Shell scripting, reading a list from tt file, use as variable, use the variable to run python scripts in a foor loop

I am trying to run a shell script where it reads the variables from a txt file, uses that variable in a for loop to run python file. The code reads a txt file where at least there are 100 variable ...
BircanA's user avatar
  • 21
0 votes
1 answer
72 views

colorizing commands vs arguments in output of shell

When working with make/cmake scripts you often have to use VERBOSE=1 and look at all the commands run. This is what I do a lot, and its utterly straining for someone just looking for the origin of ...
Kalen White's user avatar
4 votes
2 answers
1k views

How to pin a package version with `nix-shell`?

From what I understand, I can use a given version of Nix packages using the -I flag. But I would like to know if it is possible within a single shell.nix conf to have something like: git v2.1.2 htop ...
hacb's user avatar
  • 41
0 votes
0 answers
75 views

Get WID from PID using Gnome-terminal

For getting WID from PID, I use xdotool search -pid PID. In some terminals, it works correctly - outputs one number (WID of window), but in Gnome-terminal, besides WID, it outputs some other IDs. The ...
violist's user avatar
3 votes
1 answer
180 views

Launch process with limited capabilities on minimal Busybox-based system

In a minimal Busybox-based Linux system with access to the root user, how can one launch a process with a specific limited set of Linux capabilities(7) without requiring any tools beyond busybox?
Axel Fontaine's user avatar
1 vote
1 answer
67 views

optipng in parallel using shell

I would like to run optipng in parallel with my 8-thread CPU using the shell. I know the program itself is not multicore optimized, the only way will be to run 8 files with it. I have 500+ PNG images ...
Vlastimil Burián's user avatar
0 votes
1 answer
481 views

Trapping SIGINT so that the process kills itself

So section 5 from here made sense to me and I wanted to implement it. I have this bash script #!/usr/bin/env bash cp aux.sh aux.sh.bak cleanup() { cp aux.sh.bak aux.sh rm -rf aux.sh.bak } ...
leo's user avatar
  • 103
0 votes
1 answer
38 views

What is the EPS1 environment variable used in zsh prompts?

Many zsh configs floating around the internet that set the right-hand prompt RPS1 append the value of EPS1 to the end, but I have found no documentation anywhere of what EPS1 might contain. On my ...
cincodenada's user avatar
-1 votes
2 answers
161 views

Output date into specific column using bash

I want to output the date into a csv column using a bash script ignoring the header. I have this but it only gives the day of the week abbreviated and not does not place it in a specific column: date |...
robetus's user avatar
  • 113
0 votes
1 answer
315 views

Does running exec command preserves environment variables of the calling shell? If so, why?

From my understanding exec command replaces the calling shell program with the command without forking a child process. Also if I understand correctly exported variables are the ones that are passed ...
Almaz Kharrasov's user avatar
7 votes
2 answers
1k views

How do I keep a dash shell script running despite any error?

I have a dash shell script that is intended to run to the end of file: #!/usr/bin/dash # File b_shell . a_nonexistent_file echo "I want to print this line despite any previous error." ...
zanetu's user avatar
  • 171
0 votes
1 answer
81 views

Where should I put my personal shell script in terms of safety?

I am learning sh to make some customized function. I am looking for a safety location for the personal script, since I check from stack exchange, some say that put personal script under ~/bin may ...
Solarisending's user avatar