Tag Info

Hot answers tagged

18

This is located in your .bashrc: alias ll='ls -al' By taking a look at the manual pages for the command ls, you can see what those two attributes accomplish together: -a: do not ignore entries starting with .. -l: use a long listing format. So you can understand that ls -l would ignore any entry starting with .. That's their only difference. EDIT: ...


8

If the scripts directory isn't in your PATH, and . (the current directory) is not in the PATH either, you can run the script using ./ as shown below ./script_name.sh Use the script file name to run it either by using it’s relative path or absolute path as shown below: cd /home/user ./script_name.sh OR /home/user/script_name.sh


6

As other people said before me: Don't parse the output of ls! (see http://www.smallo.ruhr.de/award.html#ls) Why not simply: stat --printf='%y\t%n\n' -- * If you want to do something with each file name and time stamp, read the output of stat like this: stat --printf='%y\t%n\0' -- * | \ while IFS=$'\t' read -rd '' timestamp i; do echo "filename: ...


5

Since you have sudo access, create a sudoers file for yourself, then delete it when the script is done: # grant this user access to the sudo commands without passwords # add all required cmds to the CMDS alias sudo tee /etc/sudoers.d/$USER <<END $USER $(hostname) = NOPASSWD: /usr/bin/apt-get, /usr/sbin/adduser, /bin/rm, ... END # your script goes ...


5

ll is a common alias for ls -l. It is a part of the default .bashrc, with a couple more options: $ grep 'alias ll' /etc/skel/.bashrc alias ll='ls -alF'


5

The difference is that your current working directory would have to contain the script that you'd like to execute. In this case, the dot stands for current directory, the slash does it's normal delimiter job, then the name of the script follows. If a script was in the directory above your current working directory you could execute it using ../ It's ...


4

Something that has not been covered yet is the combination of two or three parameters, e. g. bold and underline, in a predefined color. This is achieved by a 3-way syntax, for instance: ~$ printf "\e[3;4;33mthis is a test\n\e[0m" will cause "this is a test" to be printed in yellow color (33m), italic (3m) AND underlined (4m). Note that it is not ...


4

Do not parse the output of ls, use a glob: for i in * ; do Also, quote the variables that might contain spaces: timestamp=$(stat -c %y "$i")


1

The command should be: #!/bin/bash export DISPLAY=$(echo $DISPLAY) Here you need to use the command substitution functionality i.e. $(command) of bash. EDIT: Now after seeing your full script i am getting the whole picture. First create a file in your home directory for example /home/abc/display_check having the following line: echo $DISPLAY Now ...


1

First, glen jackman was close: your script is using CR-LF (\r\n) line endings. For example, I recreated your script with CRLF line endings manually: $ cat foo.sh #!/bin/bash echo "Deleting: " $1 grep -lr $1 foo.txt | xargs echo echo "Done" $ file foo.sh foo.sh: Bourne-Again shell script, ASCII text executable, with CRLF line terminators $ sh foo.sh ...


1

The shortcuts would depend on what terminal you are using. However, most accept the -e option to specify what program to run. Therefore, for zsh you could do: x-terminal-emulator -e zsh Or, this approach to have a login shell: x-terminal-emulator -e 'zsh -l' You could then add these as aliases on your default shell or, if you prefer to have a launcher ...


1

Yes. It is possible to have multiple init processes. In the olden days before Upstart, there was just one init process (where PID = 1). Now, with Upstart, there's the original init process (where PID = 1). But, when a user logs in, a new init process is created for that user session. Thus, that is why you see the second init process (where PID != 1).


1

Here's how I do it: Install gThumb sudo apt-get install gthumb Open up nautilus and go to your images directory. Right click on one and choose Open with -> gthumb. Under the view menu choose Browser or press the Esc key. This will open the directory browser showing all your images. Press Ctrl and select the images you want to rotate or select all ...


1

Scripts are files which contains many unix commands, you can either create a file containing your commands or write those commands in Terminal directly in {} . && is used for executing the other command after previous command. In you example, mkdir -p lpi103-7 creates a directory with name lpi103-7 and cd lpi103-7 is used to change ...


1

The && notation is a boolean operator for AND, which means that it uses the result of the previous command and only executes the next command if the exit code from the first command is 0. So this is a shorthand for: ls a &> /dev/null && echo "Done" this, which basically does the same thing. ls a &> /dev/null if [ $? = 0 ]; ...



Only top voted, non community-wiki answers of a minimum length are eligible