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, …).

learn more… | top users | synonyms (1)

0
votes
0answers
10 views

.ksh session hangs after being inactive

While remotely connecting to a Linux machine using ssh, my .ksh session hangs after being inactive for sometime. If I try to type or ctrl-z, the prompt does not respond. Is there a way to restore my ...
1
vote
1answer
30 views

Shell Font Over SSH

I have a Linux machine (CentOS 7) in which I frequently SSH into from multiple devices. I have installed ZSH and Oh-my-zsh on the remote machine. I would like to install the following theme: ...
1
vote
2answers
46 views

Help me please to find my misunderstanding about this little piece of shell script

Actually, I have a folder which contains several sub folders with lots of images in each. I am trying to gather all the names of the files in each sub folder in a text file (filesNames.txt) in that ...
0
votes
1answer
47 views

Validate user response in shell script

My shell script is working fine and the files are copying to the remote directory. However I need to check if my INPUT_STRING is starting with S and also check if the files are present in the ...
0
votes
3answers
57 views

Where are shell variables stored?

For example, if I make a parameter expansion: $ b=1 $ echo $b 1 Where is b stored internally? I checked and it is not an environment variable because it is not listed by printenv. I'm writing my ...
0
votes
0answers
15 views

Unable to execute the rest of my shell script after installing Oh My Zsh [on hold]

I thought that here it will be better to ask for help with my problem. In a nutshell: I'm creating my custom shell script to simply customise my Mac. To make a short example: 1) I install OMZ using ...
38
votes
5answers
2k views

Why is the wild card character * so different between commands zip and rm?

I put together a script to do some file operations for me. I am using the wild card operator * to apply functions to all files of a type, but there is one thing I don't get. I can unzip all files in a ...
1
vote
1answer
22 views

When a shell executes an external command/program - does that program have file descriptors?

There are alot of documents and discussion around the file descriptors of shells and how those file descriptors can be manipulated for redirection etc. My question is, when a shell command is an ...
3
votes
0answers
44 views

Exploit in bash script parameter possible?

I want to pass an e-mail address from a web form to a bash script. I'm using the following regex: /[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}/ Is this sufficient? Or could one embed an ...
2
votes
2answers
27 views

efficient wait until NAS boots to mount it

Problem: Server boots 3 minutes, Raspberry Pi boots 30 seconds. After a power outage, RPi boots faster and does not mount the NAS disk. This particular RPi needs disk to be able to record to it. ...
2
votes
4answers
51 views

Create text corresponding to multiple variable assignments from a single variable

I have a variable that has a value like this line=dog,/path1,/path2 What I want is to create a variable from the value; i.e dog should be the variable and want to get the below output: ...
2
votes
1answer
27 views

Find differences of ownerships between two home folders?

I have two home folders: /home/masi and /home/masi_backup and I would like to find the differences between files of the two directories. Pseudocode vimdiff <`ls -la /home/masi` <`ls -la ...
1
vote
1answer
46 views

Get the canonical path for a command

I'm writing a script that needs canonical path of certain commands. Since there could be symbolic links pointing to the actual commands, I use readlink -f to get the canonical path. But I'm not ...
0
votes
1answer
24 views

how to echo/print block by block

I just started using tmux and butterfly and I need to scroll one panel. I tried Ctrl + b + ↑ but it scrolled the whole terminal instead of one panel. Is there any command line to display my ...
1
vote
1answer
33 views

xkill Used On Desktop

Mouse accidentally clicked on Desktop while active with an xkill terminal command. Which makes it completely without use. Have used nemo command which resets everything as long as terminal remains ...
2
votes
2answers
59 views

Split words from `read` and store to array?

How can I take input from read, split the words up by spaces, and then put those words into an array? What I want is: $ read sentence this is a sentence $ echo $sentence[1] this $ echo $sentence[2] ...
0
votes
2answers
46 views

cut -c won't work on my .sh file [closed]

I have tried the following commands cut -c-11 ifshell.sh cat ifshell.sh | cut -c-11 ifshell.sh cat ifshell.sh | awk '{print $1} | cut -c-11 ifshell.sh But every time I get the full contents of ...
1
vote
4answers
53 views

How to gather the name of the files in each subdirectory into a text file in that subdirectory?

I wanted to save the names of all files in each sub directory into a text file in that sub directory, so I wrote this script: #!/bin/bash for X in "$PWD" * do if [ -d "$X" ]; then ...
0
votes
1answer
19 views

Why does the jobs command not work in shell script?

If I run jobs -l on command prompt it shows me the status of running jobs but if I run below file ./tmp.sh #! /bin/bash jobs -l It shows empty output. Why is that and how can I obtain information ...
-1
votes
1answer
15 views

can a service like isup.me be duplicated on the system for self? [closed]

The Internet or Web as I understand it runs on variety of servers. The browser is the client which gives a URI or URL which tries to go through varied ways to connect to the web-page and render the ...
13
votes
2answers
740 views

Colored output?

When I execute a command from a terminal that prints coloured output (such as ls or gcc), the coloured output is printed. From my understanding, the process is actually outputting ANSI escape codes, ...
0
votes
3answers
51 views

Efficiently compare If variable exists and is not equal

I have a problem with the sh script syntax. I wrote a script for my Asus router. The script works perfectly. But I have this line: if [[ "$OldIP" && "$StartIP" != "$OldIP" ]]; then echo OK; ...
-1
votes
0answers
13 views

MongoDB Shell Commands

i want Run shell command(s) from MongoDB , i connect to My MongoDB With MongoVUE now i want execute shell Command like ls -l can i do it From MongoVUE ?
10
votes
14answers
2k views

'ls -1' : how to list filenames without extension

ls -1 lists my elements like so: foo.png bar.png foobar.png ... I want it listed without the .png like so: foo bar foobar ... (the dir only contains .png files) Can somebody tell me how to use ...
1
vote
1answer
20 views

tmux: how to bind a key to launch shell command?

I use tmux to develop, with two panes: one to edit the code, and one to compile it. I need to switch pane very often to launch the compile command (say "mvn install"). How can I bind a key (say ...
1
vote
1answer
44 views

Extracting files to current directory

I want to find and tar/archive all my scripts ending .sh so I wrote something like that: touch ~/archive.tar; find ~ -type f -name '*.sh' -exec rvf ~/archive.tar {} \; The problem is that after I ...
0
votes
1answer
58 views

How to pull database file from physically connected android device

I am trying to copy WeChat database file called EnMicroMsg.db so I can view it in SQLite browser. With my Nexus 7 tablet rooted and physically connected, the usb debugging checked I ran the following ...
0
votes
1answer
31 views

Is using env and export the same thing?

I'm wondering whether this (From https://www.digitalocean.com/community/tutorials/how-to-read-and-set-environmental-and-shell-variables-on-a-linux-vps): env VAR1="blahblah" command_to_run ...
0
votes
1answer
27 views

how to color specific strings in standard output and standard error [duplicate]

How do you color specific strings in standard output and standard error? For example: gpg --verify Outputs either a good signature or a bad signature string. How can I color the good one, green; ...
0
votes
2answers
39 views

How to change the language for man command? [duplicate]

I wanted to ask if it was possible to translate the man and man explanations from the terminal (in Italian language). If, for example, use: man cd Instead of running in English I would that will ...
4
votes
3answers
287 views

Remove files by regular expression

I want to keep files whose names match [0-9A-Z]{1,2}_\d{4}_\w+?\.dat, for example, A1_2001_pm23aD.dat, K_1998_12.dat, and remove the rest. However, the ls and rm commands do not support such regexes. ...
0
votes
1answer
56 views

How does this equation gives numbers random between two values?

How does this equation gives random numbers between max and min divisible by divisibleBy echo $(((RANDOM%(max-min+divisibleBy))/divisibleBy*divisibleBy+min))
18
votes
3answers
3k views

Difference between 'ls' and 'echo $(ls)'

Consider the two shell samples $ ls myDoc.html SomeDirectory someDoc.txt and $ echo $(ls) myDoc.html SomeDirectory someDoc.txt The first executes ls which, as I understand, appends the contents ...
0
votes
3answers
154 views

Where can I find the shell script for ls command? [on hold]

I am trying to understand how the ls command works, and I presume there is a shell script which defines ls somewhere in the filesystem. This correct? If so, where can I find it?
0
votes
0answers
38 views

Understanding bash script for getting drop down option

I have this script which reads the user input for executing some command, This is working fine. User=0 Path="/root/file/" Path1="/root/domain/samples/file" echo "Please select k1 l3 l8 o5 s2 s1 ...
0
votes
0answers
28 views

How do I make Web Service call in Shell Script? [closed]

Can I make a web service call in a shell script? For example, below is a web service call through cURL: curl -u graeme:abcd -i -F name=files -F filedata=@employees.csv ...
0
votes
0answers
17 views

How do I submit a header with curl? [closed]

If I want to submit a header with curl (The header being “Authorization: Bearer token”), how do I do that? I wrote this script for bash curl -i \ -H "Authorization: Bearer fefef" \ -X POST --data ...
0
votes
2answers
35 views

How to search for Viber app files

I am trying to perform filesystem extraction on viber app. my findings show that viber contains a folder named databases which contained files of interest, namely, Viber_messages, Viber_data and ...
0
votes
2answers
45 views

Cron Job: Redirecting shell script output to a file

Just an one line shell script below not working as a cron job but executing directly from terminal works fine: #!/bin/bash echo "Executed" >> ./crond.log 2>&1 What might be the ...
2
votes
1answer
28 views

How to get a list to be entered in quotes

firstly I am a total n00b with scripting, so please forgive any incorrect terminology. I have a simple script that runs a python script (used to deduplicate emails via IMAP) after a user has entered ...
1
vote
0answers
15 views

cvs auto setenv and login without typing password again

Hi I'm trying to logon to cvs automatically every time I start the machine. This works well but I have to manually type cvs login in the shell: setenv CVSROOT :pserver:$USER@vlsj-cccc:/vols/cvsroot ...
-1
votes
1answer
26 views

NodeJS - error npm undefined symbol uv_fs_realpath

i'm trying to install yo (linux) using npm npm install -g yo but i get this error : node: symbol lookup error: node: undefined symbol: uv_fs_realpath when i only type npm, it return same error ...
3
votes
2answers
329 views

Is it possible to make the variable inside nested for loop local

#!/bin/bash for i in 1 2 3 4 do # { # local i ##gives error local: can only be used in a function for i in 1 2 3 do echo "inner loop ----- $i" (( i++ )) done # } echo ...
3
votes
1answer
38 views

Bash: Why is read returning a nonzero exit status while reading my file?

I'm trying to read two files line-by-line in Bash and do something to each of their lines. Here is my Bash script: #!/usr/bin/env bash die() { echo "$@" >&2 exit 1 } extract_char() { ...
0
votes
0answers
42 views

Command is working in terminal/puTTY but not in shell script

I have set up a CS:GO server on my Linux server and have a script so restart/stop the server. In both cases a message should be printed out to the server. To accomplish that I'm using following ...
2
votes
2answers
89 views

Using tar with find

Lets say we want to find a certain files , use tar on them and delete them. I tried using touch "mycompress.bz2.tar" find . \( -name "*.c" -o -name "*.sh*" \) -exec tar ujf "mycompress.bz2.tar" {} ...
3
votes
1answer
87 views

Multiple variable assignment from different parts of one command pipeline

Say I have 2 variables that I am assigning as follows: psaux=`ps aux | grep someProcessName` pscount=`ps aux | grep someProcessName | wc -l` I would like to combine the assignments in one line, so ...
3
votes
2answers
62 views

find latest file created in folder and grep contents

I have a need to search a certain folder for the newest created file and grep the contents for a pattern. I have had ok success so far using this command: find /var/log/folder -type f -printf '%T+ ...
1
vote
2answers
38 views

How do I get my arrow keys working in the at> prompt

Whenever I try to use the arrow keys in the at> prompt (after, for example, running at now) it just shows control codes, eg. ^[[D for ←. This makes pasting and editing long commands difficult ...
0
votes
2answers
37 views

Awk: Print last N columns, where N is passed through a variable

My input variable $dirPath contains directory path. The action is to be able to retrieve the last N values in the directory path, where N is passed through a variable $depth. For a fixed N value (say ...