[root@localhost tmp]# cat /etc/passwd
[root@localhost tmp]# awk -F: '{print $1,$3,$4,$6,$7}' /etc/passwd > /tmp/pawwwd 用awk提取需要的内容 到/tmp/pawwwd下
[root@localhost tmp]# cat pawwwd 内容如下
root 0 0 /root /bin/bash
bin 1 1 /bin /sbin/nologin
daemon 2 2 /sbin /sbin/nologin
adm 3 4 /var/adm /sbin/nologin
lp 4 7 /var/spool/lpd /sbin/nologin
sync 5 0 /sbin /bin/sync
shutdown 6 0 /sbin /sbin/shutdown
halt 7 0 /sbin /sbin/halt
mail 8 12 /var/spool/mail /sbin/nologin
news 9 13 /etc/news
uucp 10 14 /var/spool/uucp /sbin/nologin
operator 11 0 /root /sbin/nologin
games 12 100 /usr/games /sbin/nologin
gopher 13 30 /var/gopher /sbin/nologin
ftp 14 50 /var/ftp /sbin/nologin
vim pawwwd 把每行所有的空格用,代替 :%s/ /,/g
mysql> use abc; 创建一个新表
mysql> create table a (name char(10),uid int,gid int,home char(40),shell char(20)); 插入表的内容规则
mysql> load data infile '/tmp/pawwwd' into table a fields terminated by ','; 导入数据
Query OK, 35 rows affected, 1 warning (0.04 sec)
Records: 35 Deleted: 0 Skipped: 0 Warnings: 1
mysql> select * from a;查看导入是否成功
转载于:https://blog.51cto.com/magicdafan/1129879