37 Answered Questions for the topic shell
./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
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
Defining a variable with or without export?
What is `export` for?
What is the difference between:
export name=value
and
name=value
Shell Linux
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?
Shell Linux
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
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?
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.
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
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/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?
Shell command to tar directory excluding certain files/folders?
Is there a simple shell command/script that supports excluding certain files/folders from being archived?
I have a directory that need to be archived with a sub directory that has a number of very...
more
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
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
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
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
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
What are the uses of the exec command in shell scripts?
Can anyone explain what are the uses of the exec command in shell scripting with simple examples?
05/22/19
Can I export a variable to the environment from a bash script without sourcing it?
suppose that I have this script
**export.bash** :
#! /usr/bin/env bash
export VAR="HELLO, VARIABLE"
when I execute the script, and try to access to the `$VAR` I get no value !
echo $VAR
...
more
05/20/19
How to determine whether a given Linux is 32 bit or 64 bit?
When I type `uname -a`, it gives the following output.
Linux mars 2.6.9-67.0.15.ELsmp #1 SMP Tue Apr 22 13:50:33 EDT 2008 i686 i686 i386 GNU/Linux
How can I know from this that the given OS is...
more
How to read a file into a variable in shell?
I want to read a file and save it in variable, but I need to keep the variable and not just print out the file.
How can I do this? I have written this script but it isn't quite what I needed:
...
more
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
How to find encoding of a file in Unix via script(s)?
I need to find the encoding of all files that are placed in a directory. Is there a way to find the encoding used?
The `file` command is not able to do this.
The encoding that is of interest to...
more
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?
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
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.