Recent Notes
Displaying keyword search results 1 - 10
Created by Dr. Xi on February 07, 2012 15:40:11
Last update: February 07, 2012 15:40:11
An alias defined in .profile does not work when you open a bash window from the desktop. Simply put, alias should be put in .bashrc ; PATH should be put in .profile . These are the facts: .profile is executed by the login shell, i.e., when you login. .bashrc is executed whenever a bash shell is opened - login or non-login. When you open a new bash window from the desktop, a non-login shell is created, it will execute .bashrc , not .profile . When you ssh to a remote system interactively, a login shell is created. When you ssh to a remote system and run a command directly, a non-login shell is created. PATH modifications should be put in .profile since it is usually...
Created by voodoo on December 08, 2011 08:52:40
Last update: December 08, 2011 08:52:40
I don't know if there's a fool proof way to find out which Linux distro you are running on, but here are some ways you can try:
cat /proc/version
cat /etc/issue
cat /etc/*release
lsb_release -a
Results on Ubuntu 11.10 oneiric:
$ cat /proc/version
Linux version 3.0.0-13-gene...
Results on Red Hat Enterprise Server:
$ cat /proc/version
Linux version 2.6.18-128.1....
Created by woolf on September 08, 2011 11:19:52
Last update: September 08, 2011 11:19:52
To check a command exists on PATH:
Use the return code of which :
which some_command &>/dev/null
[ $? -eq 0 ] || ...
For bash, use type -P :
type -P some_command &>/dev/null && echo "ome_comm...
or
check_path() {
if ! type -P $1 &> /dev/...
Created by magnum on June 23, 2011 13:01:49
Last update: June 23, 2011 13:01:49
Job control refers to the ability to selectively stop (suspend) the execution of processes and continue (resume) their execution at a later point. A user typically employs this facility via an interactive interface supplied jointly by the operating system kernel's terminal driver and bash. If the operating system on which bash is running supports job control, bash contains facilities to use it. Typing the suspend character (typically ^Z , Control-Z) while a process is running causes that process to be stopped and returns control to bash. A ^Z takes effect immediately, and has the additional side effect of causing pending output and typeahead to be discarded. Typing the delayed suspend character (typically ^Y , Control-Y) causes the process to be stopped when it attempts to...
Created by woolf on June 18, 2011 21:21:56
Last update: June 18, 2011 21:34:56
I haven't test these. They are collected for reference only. With mencoder, from HOWTO: Convert and write AVCHD (.mts) to DVD with Linux
mencoder -oac copy -ovc lavc -of mpeg -mpegopts fo... With HandBrake (GUI): Transcoding AVHD (Cannon HF100 .mts) into a usable open format (MKV w/ FFMPEG) With ffmpeg & WinFF (GUI and command line): How to convert Canon .mts video files to other formats in Ubuntu With mencoder, from Transcoding AVCHD (.mts or .m2ts) files using mencoder on Linux (no deinterlacing): # 1 pass mencoder $file -o ./$file.avi -oac cop... With ffmpeg, from Stuttering playback of canon MTS files #!/bin/bash for i in "$i"*.MTS; do name="${i%.*... #!/bin/bash for i in "$i"*.MTS; do name="${i%.*... With mencoder, from [MEncoder-users] problems with AVCHD (.mts) + Deinterlace...
Created by magnum on May 06, 2011 12:26:14
Last update: May 06, 2011 12:26:14
The bash environment variable PROMPT_COMMAND contains a regular bash command that is executed just before the command prompt is displayed.
For example:
$ export PROMPT_COMMAND=a
bash: a: command not ...
The command a is not valid so you get the error message every time you hit enter.
Echo something before $PS1 :
$ export PROMPT_COMMAND='echo -n Hi!'
Hi!$
...
PROMPT_COMMAND is regularly used to change the xterm window title. You may find this in /etc/bashrc :
case $TERM in
xterm*)
if [ -...
Created by voodoo on July 30, 2010 14:53:33
Last update: July 30, 2010 14:54:52
The -d switch for cURL sends HTTP POST with data from the command line. To verify the data being posted, this is a CGI script that echos the data back:
#!C:/perl/bin/perl.exe ## ## echo -- echos ... Examples: POST data from command line: C:\>curl -d input1=value1^&input1=value2 http://lo... POST data from stdin (with @ before the - symbol): C:\>curl -d @- http://localhost/cgi-bin/echo.pl ... POST data from a file (with @ before the - symbol and input redirect): C:\tmp>cat data.txt abcd 1234 xyz ... For some reason, @ with file name didn't work as expected: C:\tmp>curl -d @data.txt http://localhost/cgi-bin/... One thing to notice is that cURL removes the new line characters when posting (thus the echo back is only one line instead of three). This can...
Created by Dr. Xi on September 29, 2008 23:05:12
Last update: September 29, 2008 23:06:16
These variables are set or used by the Unix shell to modify its behavior. Variable Description ENV=file Name of script that gets executed at startup; Usually, ENV=$HOME/.kshrc FCEDIT=file Editor used by fc (fix command) command. If $FCEDIT is not defined, use $EDITOR, otherwise use the default (vi or ed). FPATH=dirs Directories to search for function definitions; undefined functions are set via typeset -fu . FPATH is searched when these functions are first referenced. HISTFILE=file File in which to store command history. Default is $HOME/.sh_history for Korn shell, $HOME/.bash_history for Bash. If not set, history is lost after logout. HISTSIZE=n Max number of commands to keep in history. HOME=dir Home directory; set by login from passwd file. IFS='chars' Internal field separators. Default is space, tab, and...
Created by Dr. Xi on September 29, 2008 03:38:19
Last update: September 29, 2008 03:42:44
If you used Korn shell, you know to use r to repeat a command from history. Bash does not provide the r command. But you can create an alias for such a purpose:
[peaches@dellpc ~]$ alias r='fc -s' ...
Created by Dr. Xi on September 26, 2008 22:47:26
Last update: September 26, 2008 22:47:26
In POSIX mode, bash to conform more closely to the POSIX standard by changing the behavior to match that specified by POSIX in areas where the Bash default differs. Starting bash with --posix command line option, or executing set -o posix while bash is running will cause bash to enter POSIX mode.
When invoked as sh , bash enters POSIX mode after reading the startup files:
$ ls -l /bin/sh
lrwxrwxrwx 1 root root 4 J...