linux成随机值的命令是,linux下利用(cat,strings,head,sed)命令生成随机字符串

Usage: strings [option(s)] [file(s)]

Display printable strings in [file(s)] (stdin by default)

The options are:

-a - --all Scan the entire file, not just the data section

-f --print-file-name Print the name of the file before each string

-n --bytes=[number] Locate & print any NUL-terminated sequence of at

- least [number] characters (default 4).

-t --radix={o,d,x} Print the location of the string in base 8, 10 or 16

-o An alias for --radix=o

-T --target= Specify the binary file format

-e --encoding={s,S,b,l,B,L} Select character size and endianness:

s = 7-bit, S = 8-bit, {b,l} = 16-bit, {B,L} = 32-bit

@ Read options from

-h --help Display this information

-v --version Print the program's version number

head命令用法:用法:head [选项]... [文件]...

Print the first 10 lines of each FILE to standard output.

With more than one FILE, precede each with a header giving the file name.

With no FILE, or when FILE is -, read standard input.

长选项必须用的参数在使用短选项时也是必须的。

-c, --bytes=[-]N print the first N bytes of each file;

with the leading `-', print all but the last

N bytes of each file

-n, --lines=[-]N print the first N lines instead of the first 10;

with the leading `-', print all but the last

N lines of each file

-q, --quiet, --silent never print headers giving file names

-v, --verbose always print headers giving file names

--help 显示此帮助信息并退出

--version 输出版本信息并退出

N may have a multiplier suffix: b 512, k 1024, m 1024*1024.

sed命令用法:Usage: sed [OPTION]... {script-only-if-no-other-script} [input-file]...

-n, --quiet, --silent

suppress automatic printing of pattern space

-e script, --expression=script

add the script to the commands to be executed

-f script-file, --file=script-file

add the contents of script-file to the commands to be executed

-i[SUFFIX], --in-place[=SUFFIX]

edit files in place (makes backup if extension supplied)

-c, --copy

use copy instead of rename when shuffling files in -i mode

(avoids change of input file ownership)

-l N, --line-length=N

specify the desired line-wrap length for the `l' command

--posix

disable all GNU extensions.

-r, --regexp-extended

use extended regular expressions in the script.

-s, --separate

consider files as separate rather than as a single continuous

long stream.

-u, --unbuffered

load minimal amounts of data from the input files and flush

the output buffers more often

--help display this help and exit

--version output version information and exit

If no -e, --expression, -f, or --file option is given, then the first

non-option argument is taken as the sed script to interpret. All

remaining arguments are names of input files; if no input files are

specified, then the standard input is read.

利用以上命令组合生成随机字符串

生成全字符随机的字串:

cat /dev/urandom | strings -n C | head -n L

生成数字加字母的随机字串:

cat /dev/urandom | sed 's/[^a-zA-Z0-9]//g' | strings -n C | head -n L

其中C表示字符串的字符数,L表示要生成多少行字符。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值