Code Monkey home page Code Monkey logo

shell-knowledge's People

Contributors

chuandong avatar

Watchers

 avatar  avatar

shell-knowledge's Issues

about $ value

$0 与键入的命令行一样,包含脚本文件名
$1,$2......$9 分别包含第一个到第九个命令行参数
$# 包含命令行参数的个数
$@ 包含所有命令行参数
$? 包含前一个命令的退出状态
$* 包含所有命令行参数
$$ 包含正在执行进程的ID号

cut command

cut -d : -f 1,5 /etc/passwd 表示取出passwd的第一个和第五个字段,这种多跟管道结合使用。
cut file -c 1 表示取出file内所有行的第一个字符。
sed '/foo/,/bar/ s/baz/quux/g' 表示“从含有foo行开始,再匹配是否有bar的行,再将匹配后的结果中,有baz的全部换成quux。

shell command

command &>filename 重定向command的stdout和stderr到filename中.

管道:分析前边命令的输出, 并将输出作为后边命令的输入. 这是一种产生命令链的好方法
管道可以使用多个命令的组合形式输出想要的结果,例如: cat 文件名 | grep echo | wc -l 意义是:在无内件名中寻找echo的个数。

一个命令后边跟一个& 表示在后台运行.

user->root

`#! /bin/bash

echo "change user!!!"
echo "input passwd:"
read -s passwd
while [ ! -n "$passwd" ]
do
echo "please input corrent passwd:"
read passwd
done

/usr/bin/expect <<EOF
spawn su - root
expect "Password:"
send "$passwd\r"
expect eof
EOF
echo "success!!!"
`

code

! /bin/bash

until [ -z "$1" ]
do
echo -n "$1"
shift #如果不加这句,输出就会一直循环下去, good就会在屏幕上一直打印下去
echo
done

$:./until.sh good

ps -ef

ps -ef | grep bal | grep -v grep | awk '{if ($1=="bal") print $0}' | awk '{print $9}' | sort -u
这个是查找bal用户下面不重复的服务名

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.