Top "Sh" questions

sh is the standard Unix shell since Version 7 Unix.

How to cat <<EOF >> a file containing code?

I want to print code into a file using cat <<EOF >>: cat <<EOF >&…

linux unix sh heredoc
What does the line "#!/bin/sh" mean in a UNIX shell script?

I was going through some shell script tutorials and found the following sample program: #!/bin/sh clear echo "HELLO WORLD" …

shell unix sh shebang
A variable modified inside a while loop is not remembered

In the following program, if I set the variable $foo to the value 1 inside the first if statement, it works …

bash while-loop scope sh
How to redirect output of an entire shell script within the script itself?

Is it possible to redirect all of the output of a Bourne shell script to somewhere, but with shell commands …

bash shell sh
How do I limit the number of results returned from grep?

I would like to say 10 lines max from grep. I don't want my computer to work hard. I want it …

linux bash unix sh
How to copy and edit files in Android shell?

The Android shell does not have the cp command. Android shell also has no sed or grep or vi. I …

android linux shell android-ndk sh
Count occurrences of a char in a string using Bash

I need to count the number of occurrences of a char in a string using Bash. In the following example, …

bash shell sh
Equivalent of .bat in mac os

I currently use a .bat file that is utilized to invoke a java file. If I wanted to utilize the …

macos batch-file sh
Assigning the output of a command to a variable

I am new with unix and I am writing a shell script. When I run this line on the command …

bash unix sh
How can I get the behavior of GNU's readlink -f on a Mac?

On Linux, the readlink utility accepts an option -f that follows additional links. This doesn't seem to work on Mac …

macos freebsd sh