About 474,000 results
Open links in new tab
  1. linux - What is the meaning of $? in a shell script? - Unix & Linux ...

    Feb 20, 2011 · $0-The filename of the current script. $#-The number of arguments supplied to a script. $$-The process number of the current shell. For shell scripts, this is the process ID under which they are executing.

  2. How do I run a 'sudo' command inside a script? - Ask Ubuntu

    Feb 25, 2014 · That way, all commands within the script will be run with root privileges and you only need to give the password once when launching the script. If you need a particular command within the script to be run without sudo privileges, you can run it as a regular user with (thanks Lie Ryan): sudo -u username command

  3. shell script - what is >> symbol and - Unix & Linux Stack Exchange

    See What is the difference between > and >> (especially as it relates to use with the cat program)?, What does “3>&1 1>&2 2>&3” do in a script? and of course, your shell's manual. (There are some further explanations in Is this a typo in Bash manual's redirection section? too.) –

  4. What does -f mean in an if statement in a bash script? - linux

    Jul 5, 2018 · The relevant man page to check for this is that of the shell itself, bash, because -f is functionality that the shell provides, it's a bash built-in. On my system (CentOS 7), the fine man page covers it. The grep may not give the same results on other distributions.

  5. 12.04 - Permission denied when running .sh scripts - Ask Ubuntu

    Jan 22, 2014 · @RobBell bash a type of shell program used to interpret the bash script. Its synopsis is bash [options] [command_string | file], so it is possible we execute one command like this echo "echo hello world" | bash or bash script.sh, because we don't excute script with ./ so it is even no need to add #!/bin/bash(specify the interpreter) in the script .

  6. shell - How can I get the size of a file in a bash script? - Unix ...

    The script works on many Unix systems including Linux, BSD, OSX, Solaris, SunOS, etc. The file size shows the number of bytes. It is the apparent size, which is the bytes the file uses on a typical disk, without special compression, or special sparse areas, or unallocated blocks, etc.

  7. How can I pass a command line argument into a shell script?

    The shell command and any arguments to that command appear as numbered shell variables: $0 has the string value of the command itself, something like script, ./script, /home/user/bin/script or whatever. Any arguments appear as "$1", "$2", "$3" and so on. The count of arguments is in the shell variable "$#".

  8. Shell scripting: -z and -n options with if - Unix & Linux Stack …

    You can find a very nice reference for bash's [aka test builtin's operators here, or by running help test in a bash shell or info bash test or info bash '[' from any shell¹. If you are using a different shell, just search for the description of its [ or test builtin in its documentation of if it doesn't have such a builtin², in the man page ...

  9. How to make a file (e.g. a .sh script) executable, so it can be run ...

    Aug 15, 2019 · Then we confirm the script called file_command.txt is correct. Lastly we run the script by calling bash and passing it the script name. The bashcommand is actually store as /bin/bash and it is an executable on all Ubuntu systems. Creating a file of commands saves you from adding the shebang #!/bin/bash as the first line in a script.

  10. bash - How to kill a script running in terminal, without closing ...

    Usually the parent shell guesses that the script is written for the the same shell (minimal Bourne-like shells run the script with /bin/sh, bash runs it as a bash subprocess) ... Because of this, when the script is executed, you won't find a process named after script (or a process with the script's name in the command line) and pgrep will fail.

Refresh