Just like I last posted the below script can be used to remove blank spaces from file names.
#!/bin/sh
find . -name "* *"|while read file
do
target=`echo "$file"|tr -s ' ' '_'`
mv "$file" "$target"
done
Category Archives: linux
Shell script: Rename extensions of multiple files.
Shell provides easy way of renaming multiple files.
Eg: your directory has ’01 – Song1.mp3′, ’02 – Song2.mp3′, ’03 – Song3.mp3′ and you want to rename them to .txt. use the following commane.
$rename mp3 txt *.mp3
The above command renames .mp3 files to .txt.
An alternate script solution from here
#!/bin/sh
ls *.mp3|while read file
do
target=`echo $file|cut -d . -f 1`
#mv "$file" "$target.txt"
echo "$target.txt"
done
First test the above script by seeing the echo "$target.txt" output then uncomment the line above it and comment this line.
Search and replace text in multiple files.
I had a bunch of html files where a particular style sheet inclusion had to be removed from about 500 odd html files.
Knew this could be done through an sed script , but found a better one using perl from here.
export OLD_TEXT=’<link rel=”stylesheet” type=”text/css” href=”style.css”>’
export NEW_TEXT=’some new text’
and use it in the perl command as follows.
perl -w -i -p -e “s/$OLD_TEXT/$NEW_TEXT/g” *.html
or use it against all .html files from the current directory using find and xargs
find . -name “*.html” | xargs -i perl -w -i -p -e “s/$OLD_TEXT/$NEW_TEXT/g” {}
Enable sound for 3gp videos in ubuntu using mplayer
To play 3gp videos with audio using mplayer in Ubuntu Jaunty, add the following line to your /etc/apt/sources.list file
sudo wget http://www.medibuntu.org/sources.list.d/jaunty.list --output-document=/etc/apt/sources.list.d/medibuntu.list
You need the GPG key for medibuntu packages. Get it the following way.
sudo apt-get update
sudo apt-get install medibuntu-keyring
sudo apt-get update
now install the following packages
w32codecs mplayer mencoder amrnb amrwb
You should be able to hear the sound in mplayer now.
Unable to connect Yahoo messenger in Kopete?
[UPDATE] As of now the latest update on jaunty for the kopete package, the problem is fixed in the version 4:4.2.2-0ubuntu2.
It seems Yahoo! is changing their protocols for client connection. Heard somewhere this is done to disallow 3rd party clients like pidgin and trillian access yahoo’s messenger service. On my Ubuntu Jaunty, this has not affected pidgin yet! (looks like it auto adjusted) , but for Kopete I had to override the server connection to cn.scs.msg.yahoo.com and now its working fine.
Got the workaround from here.
Kopete is the only yahoo client on linux, AFAIK that allows video chat. Not sure if anything else has surfaced up yet. Haven’t been able to use Gyache yet with my webcam.
Flex builder on Linux kept on Hold?
This post has reported that the flex builder work on linux has been put on hold. Noted Adobe techie has said “there is not enough requisition for the product to continue its development”
Well, that’s not a great news to hear.. considering the open sourced SDK of adobe flex, good amount of interest was generated in the FOSS developer community. To help it revive again, use this link to vote on the adobe site.
http://bugs.adobe.com/jira/browse/FB-19053
From the current builder available on linux ,which is infact a eclipse plugin, the main feature I missed was, the design view in it. Hopefully, when the development continues design view is also ported to linux.
Juploadr: Flickr upload tool for Linux and Mac!
Though i had found this tool long time back, it came about pretty handy while using it recently.
Get it from jUploadr
Just untar the package and run jupload from the installation folder. This launches a simple UI which allows you to drag and drop photos to it. Just add a flickr account and authorize juploadr to upload. You can add individual tags and descriptions to each of your photos. Its purely written in Java and hence portable across platforms.
Update: On ubuntu, there are other flickr upload tools too. Notably good ones are postr and dfo for gnome and kflickr for KDE.
To install simply type sudo apt-get install postr or sudo apt-get install kflickr at the terminal.
Remote Login to Linux from Windows (Non-VNC)
We can actually login to a *nix based system running X server remotely from Windows XP/Vista based machines. Although there are other ways to achieve remote login using Putty for a SSH login and file transfer over SSH using WinSCP. This particular method allows you to access the entire desktop as a independent session unlike VNC where actually you are viewing a already running X session.
Two things are required for this.
First, the *nix machine should be enabled with XDMCP protocol. Most distributions disable this with their default installation. This can be enabled if you have root or sudo access with simple steps. For eg:- for Gnome with Ubuntu, this can be achieved with System -> Administration -> Login Window. Go to the Remote tab and select Same as Local also go to the Security tab and uncheck Deny TCP connections to Xserver.
Reboot X and Thats it!
Second, In the Windows system download and install Xming. Its a free Xserver software for Windows. The installation is pretty simple. After installation launch Xlaunch from the menu.
Select One Window or Full Screen and provide the *nix host address.
If all goes well you should get the display manager running.. enter the username/password and you are tuxified!!!
Update: For a VNC like remote login, use the following for gnome.
Install vino , in ubuntu or debian like distros, use sudo apt-get install vino.
Now run vino-server from /usr/lib/vino/vino-server this will enable the vnc server. To set preferences for accepting vnc sessions run vino-preferences and configure the same.
To connect from a *nix client use vncviewer hostip. From windows install vnc client from here.
Download videos from youtube.com
Update:
On Ubuntu a better approach to download youtube videos from command line is using clive. It has options to download the best available format for the video using the -f option.
Also a to download videos directly from the youtube.com homepage a firefox extension provides a “Save As” option just below the playing video. Here again, we have option to download from HD to the lowest available resolution of the video. Get the extension from here. http://userscripts.org/scripts/show/25105
Old method below, keeping it around for the memories.!!
Recently I found a fantastic python script do download videos from youtube.com. http://www.arrakis.es/~rggi3/youtube-dl/
You just need to pass the url of the video like this
$youtube-dl -t http://youtube.com/watch?v=LNY7Lau0sJw
Below is a script which can download the videos based on your search results on youtube.com.
Suppose you make a search as Shilpa Shetty Big Brother
and you get a results page, now save this page as say results.html
Now put the below give script into a file called as youtube_download.sh and run it from the directory u saved results.html
#script to download vids from www.youtube.com
#! /bin/sh
if [ $# -lt 1 ]; then
echo "Usage: $0 filename.html |which has links from youtube.com search results"
echo "-Ajo Paul http://ajopaul.wordpress.com"
exit 1
fi
watchlink=""
for i in `cat $1 | grep "watch?" | cut -d '"' -f 2`
do
#watchlink="http://www.youtube.com"$i
if [ "$watchlink" != "$i" ]; then
echo "*********Now Downloading $i **********"
# youtube-dl -t $i 2>&1;
watchlink=$i
fi
done
echo "Done!"
echo "-Ajo Paul http://ajopaul.wordpress.com"
You can also put this script as a cronjob, but before that you must download youtube-dl and put in anywhere in your $PATH.

































