Linux

http://www.ibm.com/developerworks/cn/linux/newto/index.html#10


Bash by example, Part 1: http://www.ibm.com/developerworks/linux/library/l-bash.html

=== Casual Note ===
Define:
$ myvar='This is my environment variable!'
Notice:
* 1. there is no space on either side of the "=" sign
* 2. No double quotes instead of single quotes: disables a bash feature called expansion
Use:
$ echo $myvar
This is my environment variable!

=== home work ===
* 1. create a derectory: mkdir
* 2. create a file: touch
* 3. edit the file and insert the content:
#include <stdio.h>
#include <stdlib.h>

int main(void) {
char *myenvvar=getenv("EDITOR");
printf("The editor environment variable is set to %s\n",myenvvar);
}
to myvar.c
* 4. Save the above source into a file called myenv.c, and then compile it by issuing the command:
$ gcc myenv.c -o myenv

=== vi editor ===
* 1. vi command: vi text.txt
* 2. type "i" key: switch to edit mode
* 3. "shift+:" : switch to command mode
* 4. set line number: "shift+:" + "set nu"
* 5. save file: "ESC"-->"shift+:"-->"W" + "Enter"
* 6. quit: "shift+:" + q

=== wirte and run a shell ===
* 1. write a shell: myvar.sh
#!/bin/bash

# $1 is the first command-line argument to the script
# "${1##*.}" will remove the longest match of "*." from the beginning of the string
if [ "${1##*.}" = "tar" ]
then
echo This appears to be a tarball.
else
echo At first glance, this does not appear to be a tarball.
fi
* 2. run shell: type "chmod 755 mytar.sh" to make it executable
* 3. ./mytar.sh thisfile.tar
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值