Tag Info

New answers tagged

-1

sudo su -, which is a complicated way of writing sudo -i, constructs a pristine environment. That's the point of a login shell. Even a plain sudo removes most variables from the environment. Furthermore sudo is an external command; there's no way to elevate privileges in the shell script itself, only to run an external program (sudo) with extra privileges, ...


-1

This doesn't work because the function log_f is not declared in the sudo su - shell you launch. Instead: extVAR="yourName" sudo su - <user> << EOF log_f() { echo "LOG line: $@" } intVAR=$(date) log_f ${intVAR} ${extVAR} EOF You need to get the function defined in the root subshell. That might do it, but.... I don't know what most of ...


3

That depends on what you're doing. First of all, $PWD is an environment variable and pwd is a shell builtin or an actual binary: $ type -a pwd pwd is a shell builtin pwd is /bin/pwd Now, the bash builtin will simply print the current value of $PWD unless you use the -P flag. As explained in help pwd: pwd: pwd [-LP] Print the name of the current ...


3

$PWD is the Pathname of the current Working Directory When there are symbolic links could be different results from reading $PWD to executing the command pwd.


0

Check whether rosdep is already installed in your machine, else install sudo rosdep init rosdep update Then try the below, Install from apt-get sudo apt-get install python-rosdep python-rosinstall python-rospkg python-empy python-nose


2

String interpolation causes this. There are a number of ways to selectively prevent this from happening. The bash hackers wiki has some good examples, though the specifics may vary if you're not actually using bash. In short, you can prevent interpolation with single quotes, or you can escape the characters. [me:~/work]$ export foo=bar [me:~/work]$ echo ...


1

If you do exec bash you will use a fresh & new environnement


0

Fish shell can do this with: set -u MY_VAR 0 see http://fishshell.com/docs/current/commands.html#set


4

set | grep COLUMNS should display “Binary file (standard input) matches” (with GNU grep). muru has correctly identified the culprit: under zsh, IFS contains the null byte in addition to the standard characters space, tab, newline. Run set | grep --text COLUMNS to make grep ignore its inclination to skip binary files. Running set is not a portable, reliable ...


3

Bash variable size is not fixed.It is very likely hold arbitrary amounts of data as long as malloc can find sufficient memory and contiguous address space.Let's assume you stored large large amount of data in your variable.When you try to write data to your file,possibly you will get error something like that /bin/echo ${LARGE_DATA} >> ${YourFile} ...


3

If I were to guess, I'd suspect IFS. set lists IFS too. And for me, IFS is (space, horizontal tab, newline and nul): $ printf "%s" "$IFS" | od -a 0000000 sp ht nl nul 0000004 The presence of the NUL character (\0) causes grep to treat it as a binary file, so depending on your grep, you may see: $ set | grep COLUMNS Binary file (standard input) ...


1

No Sudo Option You can use the source command to run another bash script in the same environment you came from. (Without launching a subprocess) Script1.sh #!/bin/bash read -p "Enter Your Full Name: " Name source script2.sh Script2.sh #!/bin/bash echo $Name -- With Sudo The reason your example doesn't work is because of the sudo. You can use Sudo ...


1

To expand parameter, arithmetic and command substitutions (and not aliases and other forms of expansions), you could do: my-expand() BUFFER=${(e)BUFFER} CURSOR=$#BUFFER zle -N my-expand bindkey '\e^E' my-expand (it would have similar limitations and could be almost as dangerous as bash's one though).


1

You can set up compinit to expand parameters in your ~/.zshrc: zstyle ':completion:*' completer _expand _complete autoload -Uz compinit compinit This is a minimal setting, if you have compinit already enabled, it should be sufficient to add _expand to the settings of completer There is also the expand-word widget that is by default bound to ^X* (Ctrl+x ...


20

They serve the same purpose (pass the given env vars to the command). However a few notable differences: A=B command is a shell (Bourne/POSIX/rc) construct. For instance, you can do: A=B find . -exec cmd '{}' + or: find . -exec env A=B cmd '{}' + But you can't do: find . -exec A=B cmd '{}' + Because find is not invoking a shell to run that ...


0

On Red Hat Enterprise Linux (RHEL) 6 /etc/ld.so.conf contains include ld.so.conf.d/*.conf without this line, items in /etc/ld.so.conf.d/*.conf would never be parsed. To see which libraries / directories ldconfig is parsing ldconfig -v Print current version number, the name of each directory as it is scanned, and any links that are created.


1

Add the following to your .bashrc: vim ~/.bashrc ... export LD_LIBRARY_PATH=/usr/local/lib This will let you restart your computer, and still have that path assigned.


1

In shell scripting, there is only one data type. Everything is text. Different commands may variously interpret the text to suit their needs: $ [ "1" -eq "01" ] && echo yes || echo no yes $ [ "1" = "01" ] && echo yes || echo no no The first test interprets 1 and 01 as numbers (the second probably as an octal number). The second test treats ...


2

According to the POSIX standard, environment variables are just plain strings with no associated data types. However, as an extension, some shells like bash, ksh, ksh93, zsh and others allow their variables be typed, like being numeric, an array. Read-only variables or pre-formatted ones might also be supported. They are commonly typed with either the ...


0

you can follow through cygwin to install it, and know its shell by the shell instructions. Also here's a good resource to get started with learning learning linux commands.



Top 50 recent answers are included