tagged [shell]

Generating a SHA-256 hash from the Linux command line

Generating a SHA-256 hash from the Linux command line I know the string "foobar" generates the SHA-256 hash `c3ab8ff13720e8ad9047dd39466b3c8974e592c2fa383d4a3960714caef0c4f2` using [http://hash.online...

31 May at 12:4

How to check if running in Cygwin, Mac or Linux?

How to check if running in Cygwin, Mac or Linux? I have a shell script that is used both on Windows/Cygwin and Mac and Linux. It needs slightly different variables for each versions. How can a shell/b...

12 Aug at 09:10

Shell script : How to cut part of a string

Shell script : How to cut part of a string I have following string and would like to get the list of id ? How this can be done using sed or something else ?

17 Sep at 13:54

using rot13 and tr command for having an encrypted email address

using rot13 and tr command for having an encrypted email address I have read many tutorials on the internet about the usage of the 'tr' command. However, I am not able to understand how to encrypt an ...

13 Feb at 12:15

Difference between sh and Bash

Difference between sh and Bash When writing shell programs, we often use `/bin/sh` and `/bin/bash`. I usually use `bash`, but I don't know what's the difference between them. What's main difference be...

25 Oct at 19:20

Checking from shell script if a directory contains files

Checking from shell script if a directory contains files From a shell script, how do I check if a directory contains files? Something similar to this but which works if the directory contains one or s...

8 Feb at 21:35

How to do this on the tcsh shell in linux

How to do this on the tcsh shell in linux I want to efficiently do the following on the tcsh in Linux. If I do `somecommand {a,b,c}`, this does `somecommand a b c`, which is not what I want. Is there ...

3 Sep at 18:21

How do I use the lines of a file as arguments of a command?

How do I use the lines of a file as arguments of a command? Say, I have a file `foo.txt` specifying `N` arguments which I need to pass to the command `my_command` How do I use the lines of a file as a...

How can I check if a command exists in a shell script?

How can I check if a command exists in a shell script? I am writing my first shell script. In my script I would like to check if a certain command exists, and if not, install the executable. How would...

1 Jan at 01:8

How to use ADB Shell when Multiple Devices are connected? Fails with "error: more than one device and emulator"

How to use ADB Shell when Multiple Devices are connected? Fails with "error: more than one device and emulator" --- --- ---

5 Nov at 08:30

How to run shell script file using nodejs?

How to run shell script file using nodejs? I need to run a shell script file using nodeJS that executes a set of Cassandra DB commands. Can anybody please help me on this.

28 Feb at 19:5

Global environment variables in a shell script

Global environment variables in a shell script How to set a global environment variable in a bash script? If I do stuff like ...or ...the vars seem to stay in the local context, whereas I'd like to ke...

How can I shuffle the lines of a text file on the Unix command line or in a shell script?

How can I shuffle the lines of a text file on the Unix command line or in a shell script? I want to shuffle the lines of a text file randomly and create a new file. The file may have several thousands...

19 Jul at 04:34

Subtract two variables in Bash

Subtract two variables in Bash I have the script below to subtract the counts of files between two directories but the `COUNT=` expression does not work. What is the correct syntax? ``` #!/usr/bin/env...

31 Dec at 21:18

Display custom header or column in Windows Explorer

Display custom header or column in Windows Explorer My app adds some custom metadata to files. I want to display it in Windows Explorer like this: ![Mockup 1](https://i.stack.imgur.com/4Vh62.jpg) or t...

3 Apr at 16:41

How can I open a Shell inside a Vim Window?

How can I open a Shell inside a Vim Window? I can open a shell by using the :shell command in Vim, however I can't edit a file and at the same time use the shell. Is there any way to split Vim in many...

6 May at 16:36

How to execute mongo commands through shell scripts?

How to execute mongo commands through shell scripts? I want to execute `mongo` commands in shell script, e.g. in a script `test.sh`: When I execute this script via `./test.sh`, then the connection to ...

11 Mar at 18:41

How to run a script at the start up of Ubuntu?

How to run a script at the start up of Ubuntu? I want to run some Java programs in the background when the system boots in Ubuntu. I have tried to add a script in /etc/init.d directory but failed to s...

1 Dec at 10:29

c# execute shell command and get result

c# execute shell command and get result I am executing a command prompt command as follows: How to I get the output of the

5 Nov at 12:25

Make xargs handle filenames that contain spaces

Make xargs handle filenames that contain spaces My command fails because the file "Lemon Tree.mp3" contains spaces and so xargs thinks it's two files. Can I make find + xargs work with filenames like ...

2 Oct at 00:33

How to get key names from JSON using jq

How to get key names from JSON using jq `curl http://testhost.test.com:8080/application/app/version | jq '.version' | jq '.[]'` The above command outputs only the values as below: How can I get the ke...

28 Jul at 12:17

How to stop java process gracefully?

How to stop java process gracefully? How do I stop a Java process gracefully in Linux and Windows? When does `Runtime.getRuntime().addShutdownHook` get called, and when does it not? What about finaliz...

2 Jun at 11:45

How can I reverse the order of lines in a file?

How can I reverse the order of lines in a file? I'd like to reverse the order of lines in a text file (or stdin), preserving the contents of each line. So, i.e., starting with: I'd like to end up with...

4 Dec at 05:7

How can I put the current running linux process in background?

How can I put the current running linux process in background? I have a command that uploads files using git to a remote server from the Linux shell and it will take many hours to finish. How can I pu...

22 Jan at 16:53

How to store command results in a shell variable?

How to store command results in a shell variable? I want to find out the number of directories and files in home directory and store that in a shell variable. I am using the following set of commands....

13 Feb at 09:48