Tag Info

Hot answers tagged

16

You can use xargs and seq. Generally: seq nr_of_times_to_repeat | xargs -Iz command For example: seq 10 | xargs -Iz xdotool click 1 will execute the xdotool click 1 command for 10 times.


10

You can't use file1 > file2 to copy file1's contents to file2 because there's no command there. You have to issue some command. Redirections apply to (1) a command you run or (2) the shell as a whole (if applied to the exec builtin). But they work by changing the source or target of actions that perform input-ouptut operations--that is, that read from ...


9

Open a Terminal and use the following bash command: for i in {1..5}; do xdotool click 1; done With a bit of verbosity and 1s delay: for i in {1..5}; do echo click \#$i && xdotool click 1 && sleep 1; done click #1 click #2 click #3 click #4 click #5


8

You can use gvfs-trash instead of mv gvfs-trash somefile The reason you were unable to see your file after moving it to ~/.local/share/Trash is that there is an additional directory structure below that i.e. ~/.local/share/Trash/files to contain the actual trashed file; and ~/.local/share/Trash/info containing metadata such as the original location ...


7

You can redirect the content of text1.txt using the cat command: ~# cat /root/Documents/text1.txt > /root/Documents/text2.txt Note: you can use cat to also create new binary files, e.g: ~# cat mypic.jpg > my_new_pic.jpg


6

This is explained very nicely in the relevant section of the bash manual. Briefly, anything within single quotes is interpreted literally. So, for example: $ echo '$SHELL' $SHELL $ echo '{1..3}' {1..3} Compare that to the unquoted versions: $ echo $SHELL /bin/bash $ echo {1..3} 1 2 3 Double quotes allow variable expansion (also history expansion and ...


5

This should do: #!/bin/bash x=1 while [ $x -le 10 ] do <command to run> x=$(( $x + 1 )) done where 10 is the number of times to run the command if you need to build in a little break: #!/bin/bash x=1 while [ $x -le 10 ] do <command to run> sleep 1 x=$(( $x + 1 )) done Copy the script into an empty file, replace <command to ...


4

According to touch man page: -t STAMP use [[CC]YY]MMDDhhmm[.ss] instead of current time where: CC: First two digit of the year YY: Last two digits of the year MM: Month (two-digit numeric month) DD: Day (two-digit numeric day i.e. day of month) hh: Hour mm: Minutes ss: Seconds [] indicates that field is optional In your examples ...


3

I think you want to use graphics.h,turbo c graphics API on Ubuntu platform. For this you need to compile and install libgraph. You can download it from here. First install build-essential by typing sudo apt-get install build-essential Intall some additional packages by typing sudo apt-get install libsdl-image1.2 libsdl-image1.2-dev guile-1.8 ...


3

I have an update.sh file, which is run every night I read that as "I'm launching this via cron". A very common issue people have with cron is that they make expectations about the environment the script runs in. They assume the script will run in their home directory. That's exactly what you're doing. All your sed commands use relative paths so they ...


3

The command to start Sublime Text: subl The command to see its version: subl --version


3

You can use a C style for loop which has the advantage over the brace-expansion version ({1..5}) of being able to use variables to specify the end points. Either version is better than using an external utility (seq). t=5 for ((x = 1; x <= t; x++)) do xdotool click 1 done All on one line: t=5; for ((x = 1; x <= t; x++)); do xdotool click 1; ...


3

You can use gvfs-trash command from the package gvfs-bin which is installed by default in Ubuntu. Move file to trash: gvfs-trash filename See the content of the trash: gvfs-ls trash:// Empty the trash: gvfs-trash --empty


2

From Shutdown does not power off computer Which was originally found on Dell Studio 1569 Cannot Shutdown in Ubuntu 11.10 or 12.04 This worked for me : Type in terminal: sudo -i (to get a root shell, sudo gedit is not recommended) gedit /etc/default/grub Find the line: GRUB_CMDLINE_LINUX_DEFAULT="quiet splash" Change this to: ...


2

If refreshing is tricky, we can restart Nautilus: pkill nautilus nautilus -n Your Startup Applications entry can be easily modified to add these commands as well, as part of script, by chaining: udisks --mount ... && pkill -u nautilus && nautilus -n Nautilus has a -q option to make it quit by itself, but this doesn't work well with ...


2

Add this to your ~/.bashrc: RED="\[\033[0;31m\]" YELLOW="\[\033[1;33m\]" GREEN="\[\033[0;32m\]" BLUE="\[\033[1;34m\]" LIGHT_RED="\[\033[1;31m\]" LIGHT_GREEN="\[\033[1;32m\]" CYAN="\[\033[0;36m\]" LIGHT_CYAN="\[\033[1;36m\]" WHITE="\[\033[1;37m\]" LIGHT_GRAY="\[\033[0;37m\]" COLOR_NONE="\[\e[0m\]" ...


2

Make a script, name it cls, make it executable (chmod +x cls), and give it these contents: #!/bin/bash printf "\033c" Before you add it to your path, you may want to make sure there are no programs called cls already: update-alternatives --config cls Then, to add it to your path system-wide, put your script in a safe system location, such as ...


2

You can find the definition of all XF86 keys here: http://cgit.freedesktop.org/xorg/proto/x11proto/tree/XF86keysym.h (or installed on your system in /usr/include/X11/XF86keysym.h, if you installed x11proto-core-dev) To run it from the terminal, just install xdotool: sudo apt-get install xdotool and run: xdotool key XF86AudioRaiseVolume


2

It is a vast topic to discuss on. But considering the case of Ubuntu, the passwords are stored in the location /etc/shadow You can view the contents by opening it with sudo nano /etc/shadow On the very first line you can see root:$6$xrzOs5vu$gfLwd1NVOBRqCvmgpBOa9V4PzNOzlgC2jGU.GT8k9zPiW2zihymU/nmgdjsP8SzR3Qk7UoQUkTrsi9tCIFy6f.:16303:0:99999:7::: ...


2

If you have GNU Parallel you can run: seq 10 | parallel -N0 doit All new computers have multiple cores, but most programs are serial in nature and will therefore not use the multiple cores. However, many tasks are extremely parallelizeable: Run the same program on many files Run the same program for every line in a file Run the same program for every ...


2

The following function will print an error message if the given the name of a variable that is null or undefined: def() { : "${!1:? "Variable not defined."}" ; } Examples: $ def PATH $ def NONESUCH bash: !1: Variable not defined. This function requires bash. Explanation: The body of the function consists of one command which is given one argument. ...


1

Since Ubuntu 12.04 LTS (and perhaps a bit before that, but not as far back as 10.04 LTS), the bash version in Ubuntu has been at least 4.2. Thus it supports the -v operator for the test, [, and [[ builtins. If you only learn one way to test if variables are defined in bash, it should probably be the parameter expansion technique used in John1024's excellent ...


1

To expand on @SylvainPineau's answer, the reason you can't do /root/Documents/text1.txt > /root/Documents/text2.txt is that the thing separate from the redirect operator and the file after it has to be a command. When you execute /root/Documents/text1.txt > /root/Documents/text2.txt you are telling the shell to execute /root/Documents/text1.txt, which ...


1

Please try the following command, it should start both jobs: gnome-terminal --tab -e " sh -c ' (gedit /media/ubuntuman/Onces\ And\ for\ Al/scripts/faceBook &) ; sudo cpulimit -e ubuntu-tweak -l 80;'" Parentheses denote a subshell in bash. To quote the man page: (list) list is executed in a subshell environment (see COMMAND EXECU‐ ...


1

The usual command for Sublime Text is subl: From subl --help: $ subl --help Sublime Text build 3065 Usage: sublime_text [arguments] [files] edit the given files or: sublime_text [arguments] [directories] open the given directories Arguments: --project <project>: Load the given project --command <command>: Run the given ...


1

As far as I can tell, this menu-based interface is part of the installer, and does not exist independently. However, if and when Network Manager 0.9.10 comes to Ubuntu, you could use nmtui, the text user interface for Network Manager for a nicer interface. Other options include wicd-cli, part of WICD, a network management program.


1

@Oli told you why it is probably failing so I'll just explain the sed code: sed -i "s/tk[0-9]*;/tk$company_id;/1i" The s/PATTERN/REPLACEMENT/FLAGS is the substitution operator. It will replace PATTERN with REPLACEMENT. The FLAGS (for example, g in s///g) can modify its behavior. Here, the flags are N (1 in your example) which means "Replace only the Nth ...


1

You're not totally right regarding the meaning the sed options. Let me first explain them then we will understand what your code is doing. Option -i means : instead of displaying the result of the sed processing on the terminal, write it to the file. s/ syntax is s/regexp/replacement/. It means sed will substitute the strings matching the regular ...


1

You can't delete history like this as it will delete the history of current session. If you wan to clear your history using script use following command in your script > ~/.bash_history It is enough to clear all your bash history .


1

Running sudo chmod -R 777 /etc/ was a stupid thing to do. You probably recognise that now but you've set every file in /etc/ and its subdirectories to be readable, writable and executable by any account on the system. The files in there are mostly root owned and have permissions set for security... To stop just anybody or anything overwriting, deleting or ...



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