Batch (for loop) commands in the terminal


Sometimes I have a command to run on a list of files. Below are some examples of how to do it:

Command on a list of files in the current directory

for file in ls *; do echo $file; done

Of course you can replace echo $file by any other command. In this example it will only print a list of the filenames in the directory.

Command using variables

for i in {1,2,3,4,5}; do touch file_$i; done

Posted By yusuf read more

Using sudo without password prompt on Ubuntu


I hate having to type the password in each time I have to do admin tasks, so here's the way to disable the password prompt when using sudo.

Edit the file /etc/sudoers and put this at the end of the file:


where user is of course the name of the user to whom sudo without password prompt has to be given.

Posted By yusuf read more
Subscribe to RSS