Basic equations in bash scripts:
x=15
y=8
sum=$((x+y))
dif=$((x-y))
mod=$((x%y))
prod=$((x*y))
skip to main |
skip to sidebar
The mv command is used to rename the files.
sed parses the filename and replaces all the occurrences of "B" character with "A".
The script is case sensitive. Also, be careful with special characters that need to be escaped with "\".
For example if you have a file called ^name.txt and want to replace "^" character from the filename with "A", using the command:
will lead to the following output:
A^name.txt
You need to escape "^" character:
In this case the output will be:
Aname.txt
This script also works if you use words instead of characters.
Pages
Keep it simple stupid!
Wednesday, March 28, 2012
Tuesday, March 6, 2012
How to search a word in multiple files
1. Search a word in all the files with the .txt extension in current directory.
2. Search a word in all the files in current directory and its subdirectories.
-H = display the name of the file
-r = search recursively trough subdirectories
grep -H "word" *.txt
2. Search a word in all the files in current directory and its subdirectories.
grep -H -r "word" home/directory
-H = display the name of the file
-r = search recursively trough subdirectories
Friday, February 24, 2012
How to remove/replace a given character/word from all the filenames in current directory using sed
#!/bin/bash
extension="txt"
for files in *.$extension;
do
mv $files `echo $files | sed 's/B/A/g'`;
done;
The mv command is used to rename the files.
sed parses the filename and replaces all the occurrences of "B" character with "A".
eg. BAOBAB.txt will be replaced by AAOAAA.txt
The script is case sensitive. Also, be careful with special characters that need to be escaped with "\".
For example if you have a file called ^name.txt and want to replace "^" character from the filename with "A", using the command:
mv $files `echo $files | sed 's/^/A/g'`;
will lead to the following output:
A^name.txt
You need to escape "^" character:
mv $files `echo $files | sed 's/\^/A/g'`;
In this case the output will be:
Aname.txt
This script also works if you use words instead of characters.
Monday, February 13, 2012
Install Xara Xtreme on Ubuntu 10.04
Xara Xtreme is a leading-edge graphic tool, easy-to-use and one of the world's best free graphics program.
Xara Xtreme is supplied in autopackage format. Follow the next steps to install the program:
Download autopackage archive from
Xara Xtreme is supplied in autopackage format. Follow the next steps to install the program:
- Download the Xara Xtreme Linux installation package (http://www.xaraxtreme.org)
- Make this package executable:
- Click on "Properties".
- Click on the "Permissions" tab.
- Ensure the checkbox "Allow executing file as program" is checked.
- Click on "Close".
- Double click on .package file
- The installer will begin by prompting you whether to download the autopackage code (if autopackage is not already installed). Answer yes (or simply press Enter).
- After some time, it will display a window asking for the administrator (sudo) password. This is to install autopackage system-wide.
- After autopackage has finished installing, Xara installation will begin. You may be prompted for the password again.
- When Xara has finished installing, you should have a Xara icon in your application menu (e.g. Applications > Graphics > Xara Xtreme)
Download autopackage archive from
Followers
Fun Box
About Me
Copyright 2010 ECHO-tutorials.blogspot.com . Powered by Blogger
Blogger Templates created by Deluxe Templates Wordpress by thebookish