Tag: shell

47 votes
16 answers
1.6K views
How to mkdir only if a directory does not already exist?

I am writing a shell script to run under the KornShell (ksh) on AIX. I would like to use the mkdir command to

avatar
Yolando
0 1 0 9
asked 07 September, 2021
48 votes
30 answers
1.1K views
How do I split a string on a delimiter in Bash?

I have this string stored in a variable: IN="[email protected];[email protected]" Now I would like to split the stri

avatar
Lynette
0 1 0 9
asked 07 September, 2021
62 votes
18 answers
400 views
In the shell, what does " 2>&1 " mean?

In a Unix shell, if I want to combine stderr and stdout into the stdout stream for further manipulation, I can

avatar
Renaldo
0 1 0 9
asked 07 September, 2021
52 votes
12 answers
1.3K views
How do I copy a folder from remote to local using scp?

How do I copy a folder from remote to local host using scp? I use ssh to log in my server. Then, I would like

avatar
Scot
0 1 0 9
asked 07 September, 2021
51 votes
26 answers
2K views
How to check if a string contains a substring in Bash

I have a string in Bash: string="My string" How can I test if it contains another string? if [ $string ?? &ap

avatar
Sena
0 1 0 9
asked 07 September, 2021
51 votes
30 answers
1.5K views
How to concatenate string variables in Bash

In PHP, strings are concatenated together as follows: $foo = "Hello"; $foo .= " World"; Here, $foo becomes

avatar
Luis
0 1 0 9
asked 07 September, 2021
59 votes
30 answers
1.6K views
How can I check if a directory exists in a Bash shell script?

What command can be used to check if a directory exists or not, within a Bash shell script?

avatar
Louetta
0 1 0 9
asked 07 September, 2021
55 votes
30 answers
1.5K views
How to execute a program or call a system command?

How do you call an external command (as if I'd typed it at the Unix shell or Windows command prompt) from

avatar
Dusty
0 1 0 9
asked 07 September, 2021
53 votes
21 answers
335 views
How to execute mongo commands through shell scripts?

I want to execute mongo commands in shell script, e.g. in a script test.sh: #!/bin/sh mongo myDbName db.mycol

avatar
Roger
0 1 0 9
asked 07 September, 2021
52 votes
8 answers
541 views
Pretty print in MongoDB shell as default

Is there a way to tell Mongo to pretty print output? Currently, everything is output to a single line and it&a

avatar
Percy
0 1 0 9
asked 07 September, 2021
56 votes
22 answers
2.4K views
How can I list all collections in the MongoDB shell?

In the MongoDB shell, how do I list all collections for the current database that I'm using?

avatar
Jeff
0 1 0 9
asked 07 September, 2021