export environment variable from a bash script

February 1st, 2011 mysurface

You may want to create a bash script that export some environment variable for your shell, but infect every execution of bash script is a unique session, where the variable export within it can’t be carry backward back to the bash shell. For example you have a env.sh which contains some environment variables export HELLO=hello […]

Posted in Bash, source | Hits: 204464 | 14 Comments »

Why ‘export’ if i could just direct assign the variables in bash?

January 25th, 2011 mysurface

I can direct assign value to a variable in my bash shell why I still need the command ‘export’ ? What is the different between them? If you have doubts about this, please continue to read on it. Lets do an experiment in a bash shell: $ HELLO=world $ export HELLO2=world2 $ echo $HELLO $HELLO2 […]

Posted in Bash, export | Hits: 241863 | 15 Comments »

config file for your bash script

January 22nd, 2011 mysurface

Sometime you may wish to create a bash script to do something based on a config file, what actually was in your mind? How to implement the config file for your bash script? First I think of using command ‘cut’, where I can create a list of tag=value, then uses ‘cut‘ to read out the […]

Posted in Bash, source | Hits: 177685 | 12 Comments »

BTTB: looping for shell script under embedded linux

November 17th, 2010 mysurface

You may already realized Linux happened to appear at many places, such as web server, storage server, desktop, kiosk machine, mobile devices. Yes, more and more devices running embedded Linux. Yeah, Android is a modified version of Linux kernel too! Scarcity is still an issue, embedded Linux can be very different to Linux that hosted […]

Posted in cut, for, if, seq, Text Manipulation | Hits: 249340 | 19 Comments »

Bash script that process input from pipeline or file redirection

November 15th, 2008 mysurface

I remember I wrote a post regarding how to makes python processing string from the pipeline stream. This time, I find the needs to do it in bash script. I created a hex string splitter script for my friend who needs to decode the raw data that will be written in hex string such as […]

Posted in Bash, pipeline | Hits: 196594 | 8 Comments »

write a online manga downloader using bash

November 29th, 2007 mysurface

There are plenty of site that allows you to read manga online, but you have to tolerate for the slow access and ton’s of heavy loaded ads. You can’t download the manga directly using batch download provided by wget or any download manager. but if you know how to do bash script, you could somehow […]

Posted in Bash, seq, Text Manipulation, wget | Hits: 126515 | 10 Comments »

stupid way to make mplayer repeatly play

November 3rd, 2007 mysurface

I am so desperately wanna make mplayer repeat a song, somehow I obtain a song in flv format. I fail to figure out how to make mplayer repeat, so here make a stupid workaround with bash for. for (( ; ; )); do mplayer nicesong.flv; sleep 0.1; done Kill it by hitting ctrl+c two times […]

Posted in Bash, for, mplayer, sleep | Hits: 99082 | 19 Comments »

A Bash Completion Tip

October 25th, 2007 mysurface

Bash Completion is a powerful CLI magic for bash user, it allows users to hit tabs and have auto completions on command lines. If you have no idea what is bash completion, check out CLI magic: programmable bash completion. One of the features bash completion gives you is to hide the unknown file format from […]

Posted in Bash, complete | Hits: 110161 | 25 Comments »

How to list just directories

September 19th, 2007 mysurface

There are no such direct ways to list only directories using the UNIX/ linux famous command ls. Anyway with command combo’s, we can achieve the goal in two ways shown as below. 1. use ls -l with grep 2. use find -type d ( The statement above is WRONG, check out the simple way to […]

Posted in Bash, column, find, grep, ls, Text Manipulation | Hits: 146522 | 15 Comments »

Writing scripts that needs root permission

September 2nd, 2007 mysurface

While executing commands that needs root permission, I rely on sudo. Sudo provides me a very convenient way to execute root privilege commands from my user account provided with my user account password. Sudo and su are not the same, check out more from here. When comes to scripting, I couldn’t use sudo directly. For […]

Posted in Admin, Bash, sudo | Hits: 83229 | 17 Comments »