Skip to main content
6278 votes
66 answers
5.2m views

How do I call an external command within Python as if I had typed it in a shell or command prompt?
freshWoWer's user avatar
  • 64.6k
4550 votes
35 answers
3.5m views

What command checks if a directory exists or not within a Bash shell script?
Grundlefleck's user avatar
3657 votes
30 answers
3.4m views

I have a string in Bash: string="My string" How can I test if it contains another string? if [ $string ?? 'foo' ]; then echo "It's there!" fi Where ?? is my unknown operator. ...
davidsheldon's user avatar
  • 40.4k
3611 votes
31 answers
5.3m views

In PHP, strings are concatenated together as follows: $foo = "Hello"; $foo .= " World"; Here, $foo becomes "Hello World". How is this accomplished in Bash?
Strawberry's user avatar
  • 68.3k
3594 votes
17 answers
3.9m views

How do I copy a folder from remote to local host using scp? I use ssh to log in to my server. Then, I would like to copy the remote folder foo to local /home/user/Desktop. How do I achieve this?
Slasengger's user avatar
  • 36.2k
3253 votes
19 answers
2.0m views

To combine stderr and stdout into the stdout stream, we append this to a command: 2>&1 For example, the following command shows the first few errors from compiling main.cpp: g++ main.cpp 2>&...
Tristan Havelick's user avatar
3140 votes
19 answers
5.1m views

How can I recursively find all files in current and subfolders based on wildcard matching?
john's user avatar
  • 36k
3032 votes
40 answers
3.9m views

I have this string stored in a variable: IN="[email protected];[email protected]" Now I would like to split the strings by ; delimiter so that I have: ADDR1="[email protected]" ADDR2="[email protected]" I don't ...
stefanB's user avatar
  • 80.5k
2998 votes
17 answers
2.3m views

I am writing a shell script to run under the KornShell (ksh) on AIX. I would like to use the mkdir command to create a directory. But the directory may already exist, in which case I do not want to do ...
Spike Williams's user avatar
2517 votes
38 answers
2.5m views

How do I know if a variable is set in Bash? For example, how do I check if the user gave the first parameter to a function? function a { # if $1 is set ? }
prosseek's user avatar
  • 193k
2507 votes
16 answers
3.1m views

I have a pretty simple script that is something like the following: #!/bin/bash VAR1="$1" MOREF='sudo run command against $VAR1 | grep name | cut -c7-' echo $MOREF When I run this script from the ...
John's user avatar
  • 25.5k
2418 votes
22 answers
2.3m views

I want to write a script that loops through 15 strings (array possibly?) Is that possible? for databaseName in listOfNames then # Do something end
Mo.'s user avatar
  • 43.2k
2416 votes
22 answers
2.7m views

How would I use sed to delete all lines in a text file that contain a specific string?
A Clockwork Orange's user avatar
2324 votes
51 answers
2.0m views

How do I exclude a specific directory when searching for *.js files using find? find . -name '*.js'
helion3's user avatar
  • 38k
2273 votes
21 answers
1.9m views

How do I iterate over a range of numbers in Bash when the range is given by a variable? I know I can do this (called "sequence expression" in the Bash documentation): for i in {1..5}; do ...
eschercycle's user avatar
  • 23.6k

15 30 50 per page
1
2 3 4 5
6202