37 Answered Questions for the topic shell

06/30/19

./configure : /bin/sh^M : bad interpreter?

I've been trying to install lpng142 on my fed 12 system. Seems like a problem to me. I get this error [root@localhost lpng142]# ./configure bash: ./configure: /bin/sh^M: bad interpreter: No such... more

06/28/19

How to exclude a directory in find . command?

I'm trying to run a `find` command for all JavaScript files, but how do I exclude a specific directory? Here is the `find` code we're using. for file in $(find . -name '*.js') do java -jar... more

06/27/19

How do I test if a variable is a number in Bash?

I just can't figure out how do I make sure an argument passed to my script is a number or not. All I want to do is something like this: test *isnumber* $1 && VAR=$1 || echo "need a... more

06/26/19

How can I recursively find all files in current and subfolders based on wildcard matching?

How can I recursively find all files in current and subfolders based on wildcard matching?

06/26/19

How to append one file to another in Ubuntu Linux?

I have two files: `file1` and `file2`. How do I append the contents of `file2` to `file1` so that contents of `file1` persist the process?

06/26/19

How do I know the script file name in a Bash script?

How can I determine the name of the Bash script file inside the script itself? Like if my script is in file `runme.sh`, then how would I make it to display "You are running runme.sh" message... more

06/24/19

Defining a variable with or without export?

What is `export` for? What is the difference between: export name=value and name=value

06/20/19

How can I recursively find all files in current and subfolders based on wildcard matching?

How can I recursively find all files in current and subfolders based on wildcard matching?

06/20/19

Why doesn't "cd" work in a shell script?

I'm trying to write a small script to change the current directory to my project directory: #!/bin/bash cd /home/tree/projects/java I saved this file as proj, added execute permission with... more

06/20/19

Why doesn't "cd" work in a shell script?

I'm trying to write a small script to change the current directory to my project directory: #!/bin/bash cd /home/tree/projects/java I saved this file as proj, added execute permission with... more

06/18/19

How to append one file to another in Ubuntu Linux?

I have two files: `file1` and `file2`. How do I append the contents of `file2` to `file1` so that contents of `file1` persist the process?

06/13/19

What's the best way to send a signal to all members of a process group?

I want to kill a whole process tree. What is the best way to do this using any common scripting languages? I am looking for a simple solution.

06/13/19

Get program execution time in the shell?

I want to execute something in a linux shell under a few different conditions, and be able to output the execution time of each execution. I know I could write a perl or python script that would... more

06/12/19

What does set -e mean in a bash script?

I'm studying the content of this **preinst** file that the script executes before that package is unpacked from its Debian archive (.deb) file. The script has the following code: #!/bin/bash ... more

06/08/19

Calling an external command in Python?

How can I call an external command (as if I'd typed it at the Unix shell or Windows command prompt) from within a Python script?

06/03/19

Delete newline in Vim?

Is there a way to delete the newline at the end of a line in Vim, so that the next line is appended to the current line? For example: Evaluator<T>(): _bestPos(){ } I'd like to put this... more

05/30/19

Given two directory trees, how can I find out which files differ?

If I want find the differences between two directory trees, I usually just execute: diff -r dir1/ dir2/ This outputs exactly what the differences are between corresponding files. I'm interested... more

05/29/19

Aborting a shell script if any command returns a non-zero value?

I have a Bash shell script that invokes a number of commands. I would like to have the shell script automatically exit with a return value of 1 if any of the commands return a non-zero value. Is... more

05/27/19

How to represent multiple conditions in a shell if statement?

I want to represent multiple conditions like this: if [ ( $g -eq 1 -a "$c" = "123" ) -o ( $g -eq 2 -a "$c" = "456" ) ] then echo abc; else echo efg; fi but when I execute the script,... more

05/26/19

Loop through an array of strings in Bash?

I want to write a script that loops through 15 strings (array possibly?) Is that possible? Something like: for databaseName in listOfNames then # Do something end

05/26/19

How to assign name for a screen?

I'm using the `screen` multiplexer tool on the command shell and open a lot of screens. I then forget which process ID associates with which task. I would like to set a name for a screen but can't... more

05/26/19

How can I copy the output of a command directly into my clipboard?

How can I pipe the output of a command into my clipboard and paste it back when using a terminal? For instance: cat file | clipboard

05/21/19

How to run a shell script on a Unix console or Mac terminal?

I know it, forget it and relearn it again. Time to write it down.

05/18/19

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: foo bar baz I'd like to end up with baz bar foo Is there... more

05/06/19

How do I prompt for Yes/No/Cancel input in a Linux shell script?

I want to pause input in a shell script, and prompt the user for choices. The standard 'Yes, No, or Cancel' type question. How do I accomplish this in a typical bash prompt?
1

Still looking for help? Get the right answer, fast.

Ask a question for free

Get a free answer to a quick problem.
Most questions answered within 4 hours.

OR

Find an Online Tutor Now

Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.