Windows里是这么做得:
copy picture.png + archive.rar share_rar_in_pic.png
Linux里也可以哦:
cat picture.png archive.rar > share_rar_in_pic.png
copy picture.png + archive.rar share_rar_in_pic.png
cat picture.png archive.rar > share_rar_in_pic.png
alias dltorrent='screen /path/to/btdownloadheadless.py --display_interval 5 --spew 1'
此外还有ncurse的btdownloadcurses.py 和wx的btdownloadgui.py...
不过还是没有rtorrent强大,没有aria2c无脑...
### Handy Extract Program
extract () {
if [ -f $1 ] ; then
case $1 in
*.tar.bz2) tar xvjf $1 ;;
*.tar.gz) tar xvzf $1 ;;
*.bz2) bunzip2 $1 ;;
*.rar) unrar x $1 ;;
*.gz) gunzip $1 ;;
*.tar) tar xvf $1 ;;
*.tbz2) tar xvjf $1 ;;
*.tgz) tar xvzf $1 ;;
*.zip) unzip $1 ;;
*.Z) uncompress $1 ;;
*.7z) 7z x $1 ;;
*) echo "'$1' cannot be extracted via >extract<" ;;
esac
else
echo "'$1' is not a valid file"
fi
}
find . -type d | sed -e "s/[^-][^\/]*\// |/g" -e "s/|\([^ ]\)/|-\1/"
Alias it and have fun!!
#显示所有有效的字符集及其别名
recode -l | less
#转换Windows下的ansi文件到当前的字符集(自动进行回车换行符的转换)
recode windows-1252.. file_to_change.txt
#转换Windows下的ansi文件到当前的字符集
recode utf-8/CRLF.. file_to_change.txt
#转换Latin9(西欧)字符集文件到utf8
recode iso-8859-15..utf8 file_to_change.txt
#Base64编码
recode ../b64 < file.txt > file.b64
#Quoted-printable格式解码
recode /qp.. < file.txt > file.qp
#将文本文件转换成HTML
recode ..HTML < file.txt > file.html
#在字符表中查找某符号(e.g.欧元)
recode -lf windows-1252 | grep euro
#显示字符在latin-9中的字符映射
echo -n 0x80 | recode latin-9/x1..dump
#显示latin-9编码
echo -n 0x20AC | recode ucs-2/x2..latin-9/x
#显示utf-8编码
echo -n 0x20AC | recode ucs-2/x2..utf-8/x
#显示日历
$cal -3
#显示指定月,年的日历
$cal 9 1752
#这个星期五是几号?
$date -d fri
#今年圣诞礼拜几?
$date --date='25 Dec' +%A
#若干秒后的未来时刻时间计算
$date --date '2009-09-27 13:00:00 UTC 360000 seconds'
#显示当前某地区时间时间(可用tzselect寻找时区)
$TZ=':America/Los_Angeles' date
#定时弹对话框
$echo "DISPLAY=$DISPLAY xmessage ALARM!!" | at "NOW + 30 minutes"
#网页及附件下载
wget -nd -pHEKk [url]
#断点续传
wget -c [url]
#批量下载某类别文件
wget -r -nd -np -l1 -A '*.jpg' [url]
#定时下载
echo 'wget url' | at 01:00
#限制下载速度(32KB/s)
wget --limit-rate=32k [url]
#检查链接有效性
wget -nv --spider --force-html -i bookmarks.html
# 去掉配置文件里的注释
egrep -v '^[[:space:]]*(#|$)'
.or.
sed '/ *#/d; /^ *$/d'
#做http url链接
echo $1 | sed -e h -e 's@/@\\@g' -e G -e 's@\([^\n]*\)\n\(.*\)@\1@'
#Python 自带当前目录的Http Server
python -m SimpleHTTPServer
#寻找所有不可读的文件
find -type f ! -perm -444
#寻找不可访问的目录
find -type d ! -perm -111
#Tar拷贝目录下的所有文件到目录/where/to/并保持文件属性
( cd /copy/from && tar -c . ) | ( cd /copy/to/ && tar -x -p )
#Tar拷贝目录到远程目录并保持文件属性
( tar -c /copy/from ) | ssh -C user@remote 'cd /copy/to/ && tar -x -p'
/*
Read a random number from /dev/urandom
*/
#include <stdio.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <stdlib.h>
#include <string.h> /* for strerror(int errno) */
#include <errno.h>
extern int errno;
#define BUFS 4
/* Assumes ssize_t is 4 bytes on the system */
union U {
ssize_t mlong;
char c[4];
};
int main (void)
{
int fp,n;
char buf[BUFS+1];
union U u;
/* /dev/random only returns bytes when enough noise has
been generated from the entropy pool. Hense you may
be blocked waiting. In contrast, /dev/urandom will always
return bytes. */
if ((fp = open ("/dev/urandom", O_RDONLY)) == -1)
{
fprintf (stderr, "Can't open data: %s\n", strerror (errno));
return 1;
}
if ( ( n=read(fp, buf, BUFS )) >= 4)
{
buf[n]='\0';
u.c[0]=buf[0];
u.c[1]=buf[1];
u.c[2]=buf[2];
u.c[3]=buf[3];
// check sizes
fprintf(stderr,"%u %d sizeof(%d) sizeof(%d)\n",u.mlong,n,sizeof(u.mlong),sizeof(u));
printf("%u\n",u.mlong);
}
close(fp);
return 0;
}
$bti --proxy 127.0.0.1:8118 --host twitter --account methuselar --password XXX --action friends
/*
Finds all devices with quotas.
*/
#include <stdio.h>
#include <stdlib.h>
#include <malloc.h>
#include <mntent.h>
#include <string.h>
FILE *setdev()
{
FILE *fp;
if ((fp = setmntent(MOUNTED, "r")) == NULL) {
fprintf(stderr, "Error calling setmntent\n");
}
return fp;
}
int getdev(FILE * fp,char *device)
{
struct mntent *mnt;
char *p;
char *h;
while ((mnt = getmntent(fp)) != NULL) {
if (hasmntopt(mnt, "usrquota")) {
if ((h = hasmntopt(mnt,"loop=/dev/loop")) != NULL) {
snprintf(device,255,"%s",h+5);
p=device;
while(*p++) {
if ( *p == ',') {
*p='\0';
break;
}}
return strlen(device);
} else {
snprintf(device,255,"%s",mnt->mnt_fsname);
return strlen(device);
}
}
}
return 0;
}
int main(void)
{
FILE *fp;
char device[256];
if ((fp = setdev()) == NULL) {
fprintf(stderr, "setdev returned NULL\n");
exit(1);
}
while ( getdev(fp,device)) {
printf("%s\n", device);
}
endmntent(fp);
exit(0);
}
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <pwd.h>
int main(int argc, char **argv)
{
struct passwd *pw;
if(argc <= 1) {
printf("./getpwuid \n");
return 0;
}
pw = getpwnam(argv[1]);
if( pw != NULL ) {
printf("User name %s\n",pw->pw_name);
printf("user password %s\n",pw->pw_passwd);
printf("user id %d\n",pw->pw_uid);
printf("group id %d\n",pw->pw_gid);
printf("real name %s\n",pw->pw_gecos);
printf("home directory %s\n",pw->pw_dir);
printf("shell program %s\n",pw->pw_shell);
} else {
printf("User not found!\n");
}
return 0;
}
/*
notify if anything is modified in the current directory
*/
#define _GNU_SOURCE
#include
#include
#include
#include
static volatile int event_fd;
static volatile int event_sig;
static volatile void *event_data;
static void handler(int sig, siginfo_t *si, void *data)
{
event_fd = si->si_fd;
event_sig = sig;
event_data = data;
}
int main(void)
{
struct sigaction act;
int fd;
act.sa_sigaction = handler;
sigemptyset(&act.sa_mask);
act.sa_flags = SA_SIGINFO;
sigaction(SIGRTMIN + 1, &act, NULL);
fd = open(".", O_RDONLY);
fcntl(fd, F_SETSIG, SIGRTMIN + 1);
fcntl(fd, F_NOTIFY, DN_ACCESS|DN_MODIFY|DN_CREATE|DN_RENAME|DN_DELETE|DN_ATTRIB|DN_MULTISHOT);
while (1) {
pause();
printf("Sth happened on fd=%d\n", event_fd);
}
}
perl -MCPAN -e 'install("Email::Outlook::Message")'
perl -MCPAN -e 'install("Email::LocalDelivery")'
perl -MCPAN -e 'install("Getopt::Long")'
perl -MCPAN -e 'install("Pod::Usage")'
perl -MCPAN -e 'install("File::Basename")'
And then, go to http://www.matijs.net/software/msgconv/ and download the Perl script msgconvert.pl (see the link "script itself" near the bottom of the above-mentioned Web page).perl -w ~/msgconvert.pl ~/your_message.msgAnd your_messagemsg..mime is generated. Now open it with your favorate mail client and we are set!
#!/bin/bash
function routeadd {
route add -host 61.xxx.xxx.xxx dev ppp0
route add -host 62.xxx.xxx.xxx dev ppp0
route add -host 63.xxx.xxx.xxx dev ppp0
}
function makepptp {
echo pty \"pptp VPN.SERVER.COM --nolaunchpppd\" >> /etc/ppp/peers/pptpvpn;
echo remotename PPTP >> /etc/ppp/peers/pptpvpn;
echo require-mppe-128 >> /etc/ppp/peers/pptpvpn;
echo file /etc/ppp/options.pptp >> /etc/ppp/peers/pptpvpn;
echo ipparam pptpvpn >> /etc/ppp/peers/pptpvpn;
pppd call pptpvpn &
}
if [ -a /etc/ppp/chap-secrets ];
then
rm /etc/ppp/chap-secrets
echo $1 PPTP $2 '*' >> /etc/ppp/chap-secrets;
else
echo $1 PPTP $2 '*' >> /etc/ppp/chap-secrets;
fi
if [ -e /etc/ppp/peers/pptpvpn ];
then
rm /etc/ppp/peers/pptpvpn;
echo name $1 >> /etc/ppp/peers/pptpvpn;
makepptp;
sleep 8;
routeadd;
else
echo name $1 >> /etc/ppp/peers/pptpvpn;
makepptp;
sleep 8;
routeadd;
fipty \"pptp VPN.SERVER.COM --nolaunchpppd\"Specifies that the command script is to be used to communicate rather than a specific terminal device. In this case we are using pptp client to establishes the client side of a Virtual Private Network (VPN) using the Point-to-Point Tunneling Protocol (PPTP).route add -host 63.xxx.xxx.xxx dev ppp0Close and save the file.chmod +x pptpvpn
sudo ./pptpvpn username passwordIf everything is went correctly you should be online and ppp0 should be up. Remote server will assign IP address and other routing informationkillall pppdit will work on any distribution, its just a matter ofpptp package you will have to install..#sed "s/\(ACCEPT_KEYWORDS=\"\)~/\1/g" /etc/make.conf > /etc/make.conf#cp /etc/portage/package.keywords /etc/portage/package.keywords.back#equery -i -N list | grep \~ | sed 's/.* \(.*\) (.*/<=\1 ~amd64/' >> /etc/portage/package.keywordsmount /dev/[gentoo_root] /mnt/gentoo
mount --bind /mnt/gentoo/usr/portage/packages/ /usr/portage/packages/
quickpkg gcc
chroot /mnt/gentoo
emerge -K gcc
当然,如果分开挂了portage,那么portage和/也要分别挂上...
#!/sbin/runscript
depend() {
need net
}
start() {
ebegin "Starting ADSL"
/usr/sbin/pppoe-start
eend $? "Connection Failed"
}
stop() {
ebegin "Stopping ADSL"
/usr/sbin/pppoe-stop
eend $? "Failed to stop ADSL"
}Place this in /etc/init.d and use it as other Services!Many apps can be used like this!