Chinaunix首页 | 论坛 | 博客
  • 博客访问: 7197156
  • 博文数量: 510
  • 博客积分: 12019
  • 博客等级: 上将
  • 技术积分: 6836
  • 用 户 组: 普通用户
  • 注册时间: 2005-08-01 16:46
文章分类

全部博文(510)

文章存档

2022年(2)

2021年(6)

2020年(59)

2019年(4)

2018年(10)

2017年(5)

2016年(2)

2015年(4)

2014年(4)

2013年(16)

2012年(47)

2011年(65)

2010年(46)

2009年(34)

2008年(52)

2007年(52)

2006年(80)

2005年(22)

分类: Python/Ruby

2020-04-26 10:35:27

工作中,linux下经常用到一些操作,以下为记录。以ubuntu为主。

1、查看 当前目录大小
 du -shm ./*   #按照m显示
或 
du -shk ./*   #按照k显示

也可排序
 du -shm ./*|sort -n

2、修改ubuntu 激活root账号
   sudo passwd root
   禁用:sudo passwd -l root

3、重启动网路
 /etc/init.d/networking  restart

4、tcpdump抓包
tcpdump -X  host 10.57.220.195 and port 80 -tttt|grep http

抓取机器lo接口数据,比如常见nginx的方向代理
tcpdump -i lo -A -s 0 'tcp port 8088 and (((ip[2:2] - ((ip[0]&0xf)<<2)) - ((tcp[12]&0xf0)>>2)) != 0)'

5、挂载移动硬盘
mount -t vfat /dev/sdb1 /mnt 

//注意有时侯 用fdisk -l看不出是那个sda 还是sdb,最好插入u盘后,用dmesg,特别是vmvare虚拟机上
//dmesg-->fdisk -l --> mount -t vfat /dev/sdb1 /mnt 


//挂载windows共享目录

mount -t cifs //192.168.0.10/test  /var/www/test1  -o domain=GC,username=test,password=123456


6、编译java
  注意 CLASSPATH是要文件的不是单纯路径,配置时候可以在.bashrc内 ,也可javac时候指定.建议在.bashrc内。注意指定-classpath类路径会覆盖CLASSPATH环境变量中指定的值。也就是.bashrc定义的CLASSPATH。
 javac  ./com/sun/HelloWorld.java
注意编译时候的路径必须和package 对应,java源文件要要放到相应目录下,如上, 必须在com/sun下
运行时候同理要和路径匹配,如 java  com.sun.HelloWorld。com.sun和
/com/sun对应。

又如 经常报错 ”找不到或无法加载主类“ 主要是没按照包结构进行
本来是:java -cp ./dist/GameGate.jar gamegate.GameGate。因为主类 GameGate 在gamegate保内
。如果 java -cp ./dist/GameGate.jar GameGate 则会报上面错误。

点击(此处)折叠或打开

  1. package gamegate;

  2. public class GameGate {
  3.  private static final int PORT = 8889;
  4.  
  5. public static void main(String[] args) {
  6.     }
  7.   }




-----------------------------------------------------------------------
生成jar包
javac  ./gamesrv/LuaEngine/*.java
jar cvf LuaEngine.jar  ./gamesrv/LuaEngine/*.class

使用
import gamesrv.LuaEngine.*;
代码参考


7、创建svn用户
#若有分支放在最上层passwd文件,统一管理
htpasswd -c /home/svn/passwd user 

修改svn密码
htpasswd  /home/svn/passwd user 
 
vi authz 

[groups] 
# harry_and_sally = harry,sally # harry_sally_and_joe = harry,sally,&joe admin = lhy [documents:/] 
@admin = rw


windows下SVN如何更换用户
TortoiseSVN-->Settings-->SavedData.把“Authentication data”这一项Clear就可以了

linux 指定账号 checkout 
svn  --username=test co .

8、ubuntu下apt源设置文件
/etc/apt/sources.list  
把需要的源连接加到上面文件内,然后执行apt-get update

解决错误 How to Solve NO_PUBKEY 07DC563D1F41B907
1)apt-get install debian-keyring
2)gpg --keyring /usr/share/keyrings/debian-keyring.gpg -a --export 07DC563D1F41B907 |apt-key add -

apt-get install默认安装的目录
    dpkg -L 软件包名
    在/var/cache/apt/archives找的你安装程序的包
     用gdebi-gtk可以查看具体安装在什么位置


9、创建用户
useradd -m zhang3  -d /home/zhang3  -s /bin/bash

10、pkg-config使用
比如安装库在/usr/local/proto(一般是在configure --prefix 指定的)
export PKG_CONFIG_PATH=/usr/local/proto/lib/pkgconfig
pkg-config --libs protobuf  
pkg-config --cflags protobuf

结合编译器
 g++ `pkg-config --cflags protobuf`  client.cpp Chat.pb.cc -o cli  `pkg-config --libs protobuf`


11、myslq数据库操作
1)安装:
   apt-get install mysql-server mysql-client

2)服务器设置:
修改  my.conf
    bind-address            = 10.57.220.198 #不要是127.0.0.1
3)执行   
   ./mysqld_safe --user=mysql &
    mysqld_safe 详细参数查看资料

4)服务器授权远程以root 访问。常见1045错误(远程登录权限错误)
  在本地直接执行(mysql默认本地可登录)
  shell>mysql (或者mysql -uroot)
  
  然后

  mysql>grant all privileges on *.* to 'root'@'%' identified by '123456' with grant option;
   //注意要区分大小写root

  mysql>flush privileges;  #123456为 root密码

执行
grant之前,有时候必须插入user表  root记录,如下
mysql>INSERT INTO `user` VALUES ('%','root','*196BDEDE2AE4F84CA44C47D54D78478C7E2BD7B7','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','','','','',0,0,0,0);
GRANT ALL PRIVILEGES ON *.* TO root@"%";


远程登录错误 有时候 是没有在my.cnf设置
  bind-address            = 10.57.220.198 #不要是127.0.0.1

5)字符集问题
  查看
  mysql> status;
  修改my.conf,增加default-character-set=utf8后就全部修改为utf8。 可在用status查看
   [client]
    port = 3306
   default-character-set=utf8
   
  [mysqld]
  default-character-set=utf8
 
    5.5版本后要用
    character-set-server=utf8
    collation-server=utf8_general_ci


6)连接
mysql -h110.110.110.110 -uroot -p


7)、修改root密码
update mysql.user set password=PASSWORD("Amtf.@)!#") where user='root';

8)快速登录
 /etc/my.cnf

[mysqld]
skip-name-resolve  #增加

9)忘记密码(mysql Access denied for user root@localhost错误)
# /etc/init.d/mysql stop
# mysqld_safe --user=mysql --skip-grant-tables --skip-networking &
# mysql -u root mysql
mysql> UPDATE user SET Password=PASSWORD('newpassword') where USER='root';
mysql> FLUSH PRIVILEGES;
mysql> quit
# /etc/init.d/mysql restart
# mysql -uroot -p
Enter password: <输入新设的密码newpassword>

数据库导入导出

导出
mysqldump -h 121.36.*.* -uroot -p123456 db_01 >db_01.sql                    
导入
mysql -h121.36.*.* -uroot -p123456  db_01 < db_01 .sql



12、samba配置
实现windows下用账号密码登陆。文件创建的用户和组便会按照登陆用户的名称和组属性创建,而不是nobody
1)smb.conf配置
vi /etc/samba/smb.conf


点击(此处)折叠或打开


[global]
workgroup = ubuntugroup 
netbios name = LinuxSir05
server string = Linux Samba Server TestServer
security = share


[ubuntugroup]
path = var/www/
public = yes
writable = yes
valid users = cehua
force user = cehua
force group = cehua
available = yes
browseable = yes
create mode = 0775
directory mode = 0775




2)设置账号密码
smbpasswd -a wwm
注意wwm 必须先用useradd创建


3)、windows设置
dos cmd下
net use \\10.57.220.20\ubuntugroup  /user:wwm


4)windows访问
 \\10.57.220.20\ubuntugroup
   有时候没有写权限,此时重启动服务器下samba即可。杀掉 smbd进程 ,然后sevice smbd start
 




13、杀死进程


方法1
ps -ef|grep test|grep -v grep|awk '{print "kill -9 " $2}' |sh
方法2:


kill -9 `ps aux|grep test |awk '{print $2}'`


方法3:


ps aux|grep test |awk '{print $2}'|xargs kill -9




14、lvs-dr配置
参考 http://blog.chinaunix.net/space.php?uid=52437&do=blog&id=3182417
 
基于keepalived 的配置参考 
http://blog.chinaunix.net/space.php?uid=52437&do=blog&id=3188576




15、ubuntu安装内核源码
   sudo apt-get install linux-source 会自动安装当前版本内核的源代码到 /usr/src


16、服务管理 chkconfig
apt-get install chkconfig


1)查看chkconfig -l


2) 重启后生效 
开启: chkconfig iptables on 
关闭: chkconfig iptables off 


3) 即时生效,重启后失效 
开启: service iptables start 
关闭: service iptables stop 


4)、添加服务
 chkconfig --add iptables


5)、删除服务
chkconfig --del iptables


6)、打开端口
iptables -I INPUT -p tcp --dport 3306 -j ACCEPT
 /etc/init.d/iptables save   //一定要保存
service iptables restart 
 
iptables文件 /etc/sysconfig/iptables
#对外只开放80
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT
#限制源ip访问,其中
-A RH-Firewall-1-INPUT -s 106.2.220.66 -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT


 
17、mysql (集群)cluster配置
 参考http://blog.chinaunix.net/space.php?uid=52437&do=blog&id=3191765


18、查找并删除
删除后缀为a的文件
find out/ -name '*.o' -o -name '*.a' | xargs rm -rf


19、Linux Shell常用快捷键


shell下各种操作指令说明


http://blog.chinaunix.net/uid-52437-id-3360884.html


20、目标文件分析常用指令
1) nm a.out  列出符号和对应地址
     或者 nm -s a.out 或者  objdump -t
2)列出指定 段 
   objdump  -j name   a.out     注意,不能单独使用-j或者--section,例如"objdump -j.text a.out"是不会运行成功的。 而应该:objdump -j.got.plt -S a.out  






21、过滤打包
tar -cvzf Server.tar.gz *  --exclude="*/.svn"


22、dns配置
错误1:  ping: unknown host
解决:
vi /etc/resolv.conf


search localdomain
nameserver 202.98.96.68
nameserver 61.139.2.69


23、git相关
1)安装
apt-get install git-core
2)初始化一个 repository
  mkdir ~/git_data/
  cd git_data
  mkdir repository
  cd repository
  git init --bare myprj


3)、初始化提交  
cd ~
mkdir initial.commit
cd initial.commit
git init 


git remote add origin /home/wwm/git_data/repositories/myprj


//添加文件 test.txt
touch test.txt
git add test.txt 
git commit -m "initial commit"  
git push origin master 


4)、使用
ssh 方式:
git clone wwm@10.57.220.48:git_data/myprj mycopy  


git方式
安装git-daemon
sudo apt-get install git-daemon-run


修改
vi /etc/sv/git-daemon/run
特别注意base-path 和 --export-all
点击(此处)折叠或打开


#!/bin/sh
exec 2>&1
echo 'git-daemon starting.'
exec chpst -ugitdaemon \
  "$(git --exec-path)"/git-daemon --verbose --reuseaddr \
    --base-path=/home/wwm/git_data/repositories --export-all




git-daemon相关操作:(git协议)


关闭:sudo sv down git-daemon        
启动:sudo sv up  git-daemon 
客户端访问 git clone git://10.57.220.48/myprj




24、查找最大文件
当前目录下,在js文件中找到前20个最大
find . -name "*.js" -type f -printf "%k %p\n"| sort -rn | head -n 20 


25.抓取备份网站
 wget -m -l 2 -k -c  --exclude-directories=".git" 
 m表示要镜像网站, -l表示递归深度;-k表示把绝对链接转为相对,c表示接着下载没下载完的文件
详细 man wget吧


-c 断点续传
-r 递归下载
-nd 不递归创建目录
-np 不搜索上一层目录
-k 脱机浏览时用此项
-L 递归时不进入其它主机
-p 下载网页所需的所有文件
-A 指定要下载文件样式列表
-i 后跟一个文件指明要下载的URL


举例
点击(此处)折叠或打开
#!/bin/bash
while read src_url des_file
do
    wget -c "$src_url" -O $des_file".mp3"
done < music.txt
music.txt
点击(此处)折叠或打开


故乡是北京 
重整河山待后生








26、批量替换文件中的内容
把 当前路径下js文件中所有AAA 替换成BBB
find . -name "*.js" |xargs perl -pi -e 's|AAA|'BBB'|g'


也可用ultraedit  中的文件内容替换来进行,
举例如下a.js文件,其内有
var COMM = require('../Common/common.js').GetInstance();


查找:(require.)§?\/(.?)替换为:$1$2注意要选择perl正则表达式引擎结果varCOMM=require(′common.js′).GetInstance();也可在linux下直接find.?name"?.js"|xargsperl?pi?e′s/(require\(.)§?\/(.+.)§?\/(.?)替换为:$1$2注意要选择perl正则表达式引擎结果varCOMM=require(′common.js′).GetInstance();也可在linux下直接find.?name"?.js"|xargsperl?pi?e′s/(require\(.)§?\/(.+;?)/$1$2/g'
此类批量处理方式,在重构代码中有很大的好处,可大大提高效率。基础还是要熟练使用perl




补充:更加完美形式
 find . -type f -name "*" -print0  |xargs -0 -n 30 perl -pi -e 's|AAAAA|'BBBBB'|g'   
 -print0 xargs -0 处理有空格文件名或路径;
-n  30  处理 参数过多问题,使得xargs 按照30一批处理


26、统计多个文件内,某个单词出现的次数


查找txt文件中 world文件出现的次数


find . -name "*.txt"|xargs awk 'BEGIN {num = 0} {i = 1;while(i <= NF) {if($i == "world") num++;i++}} END{print "num = "num}'  


26、统计小例子
   1)统计文件中出现次数最多的前10个单词
      cat words.txt | sort | uniq -c | sort -k1,1nr | head -10
      
  参考http://blog.sina.com.cn/s/blog_5dce657a01012ddi.html
  说明:
      sort:  对单词进行排序
      uniq -c:  显示唯一的行,并在每行行首加上本行在文件中出现的次数
      sort -k1,1nr:  按照第一个字段,数值排序,且为逆序
      head -10:  取前10行数据


   2)统计重复文件的数量
    find . -name "*.js"|awk -F '/' '{print $NF}'|sort|uniq -c | sort -k1,1nr | awk '$1>1 {print $2,$1}'


  说明:$NF最后一个域名
        $1>1 是条件方式表示相同文件大于1


27、常用find指令
  从含svn中复制文件
   find /home/work -name "*" |grep -v ".svn"|xargs cp -R --target-directory=.


28、cassandra 资源限制设置(open file)
 vi /etc/security/limits.conf
 如cassandra配置要求


点击(此处)折叠或打开


* soft nofile 32768
* hard nofile 32768
root soft nofile 32768
root hard nofile 32768
* soft memlock unlimited
* hard memlock unlimited
root soft memlock unlimited
root hard memlock unlimited
* soft as unlimited
* hard as unlimited
root soft as unlimited
root hard as unlimited
另外,要执行
sysctl -w vm.max_map_count=131072


29、简单vsftp配置
 1)、准备
 apt-get install vsftpd
 
 vi /etc/shells
        添加/bin/false 
        
2)、创建文件
touch /etc/vsftpd.chroot_list  #用于限制目录访问
touch /etc/vsftpd.user_list    #用于开发能访问的ftp账号


注意 ftpusers 内账号是限制访问的
        
3)、创建ftp目录和组
mkdir /home/ftp 
addgroup ftp
chown ftp:ftp /home/ftp  
        
4)、配置vsftpd.conf文件


#访问路径指定
增加两行
anon_root=/home/ftp
local_root=/home/ftp




去掉注释:
chroot_local_user=YES
chroot_list_enable=YES
chroot_list_file=/etc/vsftpd.chroot_list


#写权限
local_umask=022
local_enable=YES
write_enable=YES


5)、添加访问用户


adduser --shell /bin/false --home /home/ftp test
usermod  -aG ftp  test


同时修改  vsftpd.user_list 


6)、service vsftpd restart




30、流量测试工具 ntop
安装:sudo apt-get install ntop
操作:sudo /etc/init.d/ntop restart(stop,start)
观察:




31、查看进程开始运行时间


ps -p pid -o lstart #pid是进程号




for pid in $(pgrep node); do echo -n "${pid} " ; ps -p ${pid} -o lstart | grep -v "START" ; done 


其中 node 表示是程序




32、nginx+php-fpm 在centos下安装
  1)、安装nginx
   
  准备:wget
    sudo  yum install nginx  
    sudo chkconfig --level 345 nginx on  


  2)、安装php-fpm
    sudo yum --enablerepo=remi install php php-fpm  (核心组价)
    sudo   yum --enablerepo=remi install php-gd php-mysql php-mbstring php-xml php-mcrypt 
    sudo chkconfig --level 345 php-fpm on  


  3)、配置
  
  location ~ \.php$ {
        root           html;
        fastcgi_pass   127.0.0.1:9000;
        fastcgi_index  index.php;
        #fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
        fastcgi_param SCRIPT_FILENAME   /home/www$fastcgi_script_name;
      
        include        fastcgi_params;
    }


4)、php测试
  vi info.php
      phpinfo();
   ?>


   


33、ubuntu下svn server建立
1)、sudo apt-get install subversion
2)、创建svn目录(存放所有项目,既是根目录)
 sudo mkdir /home/svn
3)、创建项目 test
 sudo svnadmin create /home/svn/test
4)、修改配置
 svnserver.conf文件
打开下面四个(去掉前面#,注意前面不要有空格)
anon-access = read
auth-access = write
authz-db = authz
password-db = passwd


passwd文件


[users] 
# sally = sallyssecret
#按照样式添加即可
test = abcd


authz文件
按照样式添加即可,如下
[/]
wwm = rw


5)重启动svnserver
 sudo svnserve -d -r /home/svn
注意路径是根目录


34、linux cache增加过大




点击(此处)折叠或打开


sync #防止丢失数据


#To free pagecache
sudo echo 1 > /proc/sys/vm/drop_caches 


#To free dentries and inodes 
sudo echo 2 > /proc/sys/vm/drop_caches


#To free pagecache, dentries and inodes
sudo echo 3 > /proc/sys/vm/drop_caches
sudo echo 0 > /proc/sys/vm/drop_caches
不过系统在内存不够时候,会自动释放。            




35、导出svn脚本呢。可方便备份


通过分析日志时间进行备份
如./exportSvn home/svn/projects 2014-04-03


 表示2014-04-03以后更新的将被导出
     
                           


点击(此处)折叠或打开


#!/bin/bash


#cmd example
#./exportSvn home/svn/projects 2014-04-03




#example
#svn log -l 1 file:///home/svn/projects/lordServer/|awk '{print $5,$6}'


headtag=$1;
#timetag="2000"
timetag=$2


filelist=`ls -a $1`


for file in $filelist
do
        if [ "$file" == "." ] || [ "$file" == ".." ]
        then
                continue
        fi


        tmp=`svn log -l 1 file:///$headtag$file|awk '{print $5,$6}'`
        if [ "$tmp" == " " ]
        then
                continue
        fi


        if [[ "$tmp"<"$timetag" ]]
        then
                continue
        fi
        echo $file,$tmp
        tmp=" svn export file:///"$headtag$file" ./"$file
        $tmp
done
以下脚本压缩当前导出的各个项目目录


点击(此处)折叠或打开


#!/bin/sh


filelist=$(ls)
echo "hello"
for file in $filelist
do
        if [ -d $file ]
        then
                #tar -cvzf "/home/tmp/"$file.tar.gz $file
                tar -cvzf $file.tar.gz $file
                echo $file
        fi
done


36、根据监听端口查进程


比如查 8089端口             
1)sudo netstat -anp|grep 8089
tcp        0      0 0.0.0.0:8089     0.0.0.0:*       LISTEN      5086/nginx
2)使用ps查看进程情况 
 ps -ef|grep 5086
root      5086     1  0 Apr02 ?        00:00:00 nginx: master process /usr/sbin/nginx -c /etc/nginx/nginx.conf
                                         


             


37、直接用shell向mysql导入数据


点击(此处)折叠或打开


cat test.dat |awk '{print "insert into tt(a, b) values(\"" $1 "\", \"" $2 "\")" }'|while read line
do
   mysql -h172.28.14.110 -uroot -p123456 -D test -e "${line}"
   #echo $line
done
test.dat
点击(此处)折叠或打开


hello wwm
good yyyy
111 222


38、监控脚本


mon.sh  下面是一个列子,其他可稍作修改


点击(此处)折叠或打开


#!/bin/bash


cur_path=`pwd`;


check() {
            id=`ps aux|grep node|grep $cur_path|awk {'print $2'}`;
            echo $id
            if [ x"$id" = x ] ; then
                run_path=$cur_path"/gameServer.js";  #此处可自行修改
                                nohup node $run_path >/dev/null 2>&1 &
                echo "restarted";
        else
                echo "runing";
      fi
}


while true
do
        check;
        sleep 2 
done
start.sh


点击(此处)折叠或打开


cur_path=`pwd`;




id=`ps aux|grep mon.sh|grep $cur_path|awk {'print $2'}`;
echo $id
if [ x"$id" = x ] ; then
        nohup $cur_path/mon.sh >/dev/null 2>&1 & 
else
        echo "runing";
fi
stop.sh


点击(此处)折叠或打开


#!/bin/bash
cur_path=`pwd`;


kill -9 `ps -ef|grep mon.sh|grep -v grep|grep $cur_path|awk {'print $2'}`
kill -1 `ps -ef|grep node|grep -v grep|grep $cur_path|awk {'print $2'}`


39、windowns下清理.svn文件目录


点击(此处)折叠或打开


import urllib2 
import urllib 
import os 
import shutil 
  
def walk_dir(homedir,topdown=True): 
    for root, dirs, files in os.walk(homedir, topdown): 
        #for name in files: 
            #if name=='.svn': 
                #print(os.path.join(name)) 
                #os.remove(os.path.join(name)) 
  
        for name in dirs: 
            if name=='.svn': 
                print('Delete '+os.path.join(root,name)) 
                shutil.rmtree(os.path.join(root,name),ignore_errors=False) 




homedir = os.getcwd() 
walk_dir(homedir)




40、FFmpeg 给视频增加黑边
这个办法可以保持图片不拉伸变形前提下,改变图片尺寸


使用FFmpeg给视频增加黑边需要用到 pad 这个滤镜,具体用法如下:
   -vf pad=1280:720:0:93:black




按照从左到右的顺序依次为:
   “宽”、“高”、“X坐标”和“Y坐标”,宽和高指的是输入视频尺寸(包含加黑边的尺寸),XY指的是视频所在位置。




比如一个输入视频尺寸是1280x534的源,想要加上黑边变成1280x720,那么用上边的语法可以实现,93是这样得来的,(720-534)/2。




如果视频原始1920x800的话,完整的语法应该是:
   -vf 'scale=1280:534,pad=1280:720:0:93:black'




先将视频缩小到1280x534,然后在加入黑边变成1280x720,将1280x534的视频放置在x=0,y=93的地方,
FFmpeg会自动在上下增加93像素的黑边。
注:black可以不写,默认是黑色


看如下列子:
1)ffmpeg -i 5bd502731afe6d075b352a793d605a8b.mp4 -y -f  image2  -ss 00:00:03 -vframes 1 -vf 'scale=iw:640,pad=1280:640:640-iw/2:0:black' a.png




2)ffmpeg -i 5bd502731afe6d075b352a793d605a8b.mp4 -y -f  image2  -ss 00:00:03 -vframes 1 -vf 'scale=iw:ih,pad=1280:ih:640-iw/2:0:black' a.png  这个是保持高度,宽度增加黑边了


41、去掉首行
awk 'FNR!=1 { print }
 
比如
cat a.csv |awk 'FNR!=1 { print }'

42、批量替换


 sed -i "s/AAA/"BBB"/g" `grep  -rl "AAA"   *`

 sed -i "s/data-hi=\"hi-[0-9]*\" data-cc=\"[0-9]*\"/""/g" `grep  -rl "data-hi=\"hi-[0-9]*\" data-cc=\"[0-9]*\""   *`

首先用
grep  "data-hi=\"hi-[0-9]*\" data-cc=\"[0-9]*\""   *

43、统计单词中的字母出现次数
echo "13041041493" |awk -F"0" '{print NF-1,$0}'|sort -k1,1nr

cat  f.txt |awk -F"0" '{print NF-1,$0}'|sort -k1,1nr

44、对比两个文本文件找出不同行

命令如下:grep -vwf file1 file2

统计file1中没有,file2中有的行。不是求差别,差别用diff。就是找file1没有的



阅读(5134) | 评论(0) | 转发(0) |
0

上一篇:安装tensorflow

下一篇:python常见正则记录

给主人留下些什么吧!~~