head

输出文件的开头的内容,打印每个文件开头的内容(默认为10行).

语法

  head [options]... [file]...

选项:

  -c BYTES
  --bytes=BYTES
      指定显示头部内容的字符数;
  -n N
  --lines=N
      指定显示头部内容的行数;

  -q
  --quiet
  --silent
      不显示文件名的头信息。

  -v
  --verbose
       总是显示文件名的头信息;

例子

从文件中提取前85行:

$ head -85 file,txt

从文件中提取40-50行,首先使用head获取前50行然后使用tail获取最后10行

$ head -50 file.txt | tail -10

head 命令实例:

linux命令:head -1000 < lines.txt | tail -1 -1 tail | lines.txt < -1000 head head -1000 < lines.txt | tail -1rootopen.com
linux命令:head -1000 < lines.txt | tail -1 -1 tail | lines.txt < -1000 head head -1000 < lines.txt | tail -1rootopen.com
2018-03-27 05:41:48

linux命令:head -c $((<pw-lenght>-2)) /dev/urandom | uuencode -m - | sed -e '1d' -e '3d' | sed -e 's/=.*$//g' 's/=.*$//g' -e sed | '3d' -e '1d' -e sed | - -m uuencode | /dev/urandom $((<pw-lenght>-2)) -c head head -c $((<pw-lenght>-2)) /dev/urandom | uuencode -m - | sed -e '1d' -e '3d' | sed -e 's/=.*$//g'rootopen.com
linux命令:head -c $((<pw-lenght>-2)) /dev/urandom | uuencode -m - | sed -e '1d' -e '3d' | sed -e 's/=.*$//g' 's/=.*$//g' -e sed | '3d' -e '1d' -e sed | - -m uuencode | /dev/urandom $((<pw-lenght>-2)) -c head head -c $((<pw-lenght>-2)) /dev/urandom | uuencode -m - | sed -e '1d' -e '3d' | sed -e 's/=.*$//g'rootopen.com
2018-04-06 05:35:48

linux命令:head -$(($RANDOM % $(wc -l < file.txt) +1 )) file.txt | tail -1 -1 tail | file.txt )) +1 file.txt) < -l $(wc % -$(($RANDOM head head -$(($RANDOM % $(wc -l < file.txt) +1 )) file.txt | tail -1rootopen.com
linux命令:head -$(($RANDOM % $(wc -l < file.txt) +1 )) file.txt | tail -1 -1 tail | file.txt )) +1 file.txt) < -l $(wc % -$(($RANDOM head head -$(($RANDOM % $(wc -l < file.txt) +1 )) file.txt | tail -1rootopen.com
2018-01-29 19:48:48

linux命令:head -c4 /dev/urandom | od -N4 -tu4 | sed -ne '1s/.* //p' //p' '1s/.* -ne sed | -tu4 -N4 od | /dev/urandom -c4 head head -c4 /dev/urandom | od -N4 -tu4 | sed -ne '1s/.* //p'rootopen.com
linux命令:head -c4 /dev/urandom | od -N4 -tu4 | sed -ne '1s/.* //p' //p' '1s/.* -ne sed | -tu4 -N4 od | /dev/urandom -c4 head head -c4 /dev/urandom | od -N4 -tu4 | sed -ne '1s/.* //p'rootopen.com
2018-03-31 17:26:48

linux命令:head -c10 <(echo $RANDOM$RANDOM$RANDOM) $RANDOM$RANDOM$RANDOM) <(echo -c10 head head -c10 <(echo $RANDOM$RANDOM$RANDOM)rootopen.com
linux命令:head -c10 <(echo $RANDOM$RANDOM$RANDOM) $RANDOM$RANDOM$RANDOM) <(echo -c10 head head -c10 <(echo $RANDOM$RANDOM$RANDOM)rootopen.com
2018-04-02 17:26:48

linux命令:head -n X | tail -n 1 1 -n tail | X -n head head -n X | tail -n 1rootopen.com
linux命令:head -n X | tail -n 1 1 -n tail | X -n head head -n X | tail -n 1rootopen.com
2018-05-21 10:53:48

linux命令:head -n 20 <filename> | tail tail | <filename> 20 -n head head -n 20 <filename> | tailrootopen.com
linux命令:head -n 20 <filename> | tail tail | <filename> 20 -n head head -n 20 <filename> | tailrootopen.com
2018-03-11 07:33:48

linux命令:head -100000 /dev/urandom | strings > temp.txt && for w in $(cat webster-dictionary.txt); do if [ ${#w} -gt 3 ]; then grep -io $w temp.txt; fi; done done fi; temp.txt; $w -io grep then ]; 3 -gt ${#w} [ if do webster-dictionary.txt); $(cat in w for && temp.txt > strings | /dev/urandom -100000 head head -100000 /dev/urandom | strings > temp.txt && for w in $(cat webster-dictionary.txt); do if [ ${#w} -gt 3 ]; then grep -io $w temp.txt; fi; donerootopen.com
linux命令:head -100000 /dev/urandom | strings > temp.txt && for w in $(cat webster-dictionary.txt); do if [ ${#w} -gt 3 ]; then grep -io $w temp.txt; fi; done done fi; temp.txt; $w -io grep then ]; 3 -gt ${#w} [ if do webster-dictionary.txt); $(cat in w for && temp.txt > strings | /dev/urandom -100000 head head -100000 /dev/urandom | strings > temp.txt && for w in $(cat webster-dictionary.txt); do if [ ${#w} -gt 3 ]; then grep -io $w temp.txt; fi; donerootopen.com
2018-01-27 05:44:48

linux命令:head -100000 /dev/urandom | strings|tr '[A-Z]' '[a-z]'|sort >temp.txt && wget -q http://www.mavi1.org/web_security/wordlists/webster-dictionary.txt -O-|tr '[A-Z]' '[a-z]'|sort >temp2.txt&&comm -12 temp.txt temp2.txt temp2.txt temp.txt -12 >temp2.txt&&comm '[a-z]'|sort '[A-Z]' -O-|tr http://www.mavi1.org/web_security/wordlists/webster-dictionary.txt -q wget && >temp.txt '[a-z]'|sort '[A-Z]' strings|tr | /dev/urandom -100000 head head -100000 /dev/urandom | strings|tr '[A-Z]' '[a-z]'|sort >temp.txt && wget -q http://www.mavi1.org/web_security/wordlists/webster-dictionary.txt -O-|tr '[A-Z]' '[a-z]'|sort >temp2.txt&&comm -12 temp.txt temp2.txtrootopen.com
linux命令:head -100000 /dev/urandom | strings|tr '[A-Z]' '[a-z]'|sort >temp.txt && wget -q http://www.mavi1.org/web_security/wordlists/webster-dictionary.txt -O-|tr '[A-Z]' '[a-z]'|sort >temp2.txt&&comm -12 temp.txt temp2.txt temp2.txt temp.txt -12 >temp2.txt&&comm '[a-z]'|sort '[A-Z]' -O-|tr http://www.mavi1.org/web_security/wordlists/webster-dictionary.txt -q wget && >temp.txt '[a-z]'|sort '[A-Z]' strings|tr | /dev/urandom -100000 head head -100000 /dev/urandom | strings|tr '[A-Z]' '[a-z]'|sort >temp.txt && wget -q http://www.mavi1.org/web_security/wordlists/webster-dictionary.txt -O-|tr '[A-Z]' '[a-z]'|sort >temp2.txt&&comm -12 temp.txt temp2.txtrootopen.com
2018-02-08 21:24:48

linux命令:head -n1 sample.txt | tail -n1 -n1 tail | sample.txt -n1 head head -n1 sample.txt | tail -n1rootopen.com
linux命令:head -n1 sample.txt | tail -n1 -n1 tail | sample.txt -n1 head head -n1 sample.txt | tail -n1rootopen.com
2018-05-03 09:51:48

linux命令:head /dev/urandom | md5sum | base64 base64 | md5sum | /dev/urandom head head /dev/urandom | md5sum | base64rootopen.com
linux命令:head /dev/urandom | md5sum | base64 base64 | md5sum | /dev/urandom head head /dev/urandom | md5sum | base64rootopen.com
2018-05-01 08:29:48

linux命令:head -n 13 /etc/services | tail -n 1 1 -n tail | /etc/services 13 -n head head -n 13 /etc/services | tail -n 1rootopen.com
linux命令:head -n 13 /etc/services | tail -n 1 1 -n tail | /etc/services 13 -n head head -n 13 /etc/services | tail -n 1rootopen.com
2018-04-30 04:45:48

linux命令:head -n1 nation.tbl | sed 's/\(.\)/\1\n/g' | sort | uniq -c | grep \| | awk '{ print $1 }' }' $1 print '{ awk | \| grep | -c uniq | sort | 's/\(.\)/\1\n/g' sed | nation.tbl -n1 head head -n1 nation.tbl | sed 's/\(.\)/\1\n/g' | sort | uniq -c | grep \| | awk '{ print $1 }'rootopen.com
linux命令:head -n1 nation.tbl | sed 's/\(.\)/\1\n/g' | sort | uniq -c | grep \| | awk '{ print $1 }' }' $1 print '{ awk | \| grep | -c uniq | sort | 's/\(.\)/\1\n/g' sed | nation.tbl -n1 head head -n1 nation.tbl | sed 's/\(.\)/\1\n/g' | sort | uniq -c | grep \| | awk '{ print $1 }'rootopen.com
2018-03-30 03:01:48

linux命令:head -c7 /dev/urandom|base64|tr -d '=' '=' -d /dev/urandom|base64|tr -c7 head head -c7 /dev/urandom|base64|tr -d '='rootopen.com
linux命令:head -c7 /dev/urandom|base64|tr -d '=' '=' -d /dev/urandom|base64|tr -c7 head head -c7 /dev/urandom|base64|tr -d '='rootopen.com
2018-03-23 14:51:48

linux命令:head -c20 /dev/urandom | xxd -ps -ps xxd | /dev/urandom -c20 head head -c20 /dev/urandom | xxd -psrootopen.com
linux命令:head -c20 /dev/urandom | xxd -ps -ps xxd | /dev/urandom -c20 head head -c20 /dev/urandom | xxd -psrootopen.com
2018-05-12 20:50:48

linux命令:head -c 24 /dev/urandom | base64 base64 | /dev/urandom 24 -c head head -c 24 /dev/urandom | base64rootopen.com
linux命令:head -c 24 /dev/urandom | base64 base64 | /dev/urandom 24 -c head head -c 24 /dev/urandom | base64rootopen.com
2018-02-25 20:12:48

linux命令:head -1 file.csv | tr ',' '\n' | tr -d " " | awk '{print NR,$0}' NR,$0}' '{print awk | " " -d tr | '\n' ',' tr | file.csv -1 head head -1 file.csv | tr ',' '\n' | tr -d " " | awk '{print NR,$0}'rootopen.com
linux命令:head -1 file.csv | tr ',' '\n' | tr -d " " | awk '{print NR,$0}' NR,$0}' '{print awk | " " -d tr | '\n' ',' tr | file.csv -1 head head -1 file.csv | tr ',' '\n' | tr -d " " | awk '{print NR,$0}'rootopen.com
2018-02-19 21:27:48

linux命令:head -n1 | xargs -I {} aws sts get-session-token --serial-number $MFA_ID --duration-seconds 900 --token-code {} --output text --query [Credentials.AccessKeyId,Credentials.SecretAccessKey,Credentials.SessionToken] [Credentials.AccessKeyId,Credentials.SecretAccessKey,Credentials.SessionToken] --query text --output {} --token-code 900 --duration-seconds $MFA_ID --serial-number get-session-token sts aws {} -I xargs | -n1 head head -n1 | xargs -I {} aws sts get-session-token --serial-number $MFA_ID --duration-seconds 900 --token-code {} --output text --query [Credentials.AccessKeyId,Credentials.SecretAccessKey,Credentials.SessionToken]rootopen.com
linux命令:head -n1 | xargs -I {} aws sts get-session-token --serial-number $MFA_ID --duration-seconds 900 --token-code {} --output text --query [Credentials.AccessKeyId,Credentials.SecretAccessKey,Credentials.SessionToken] [Credentials.AccessKeyId,Credentials.SecretAccessKey,Credentials.SessionToken] --query text --output {} --token-code 900 --duration-seconds $MFA_ID --serial-number get-session-token sts aws {} -I xargs | -n1 head head -n1 | xargs -I {} aws sts get-session-token --serial-number $MFA_ID --duration-seconds 900 --token-code {} --output text --query [Credentials.AccessKeyId,Credentials.SecretAccessKey,Credentials.SessionToken]rootopen.com
2018-01-25 16:36:48

linux命令:head filename.txt | column -t -s $'\t' $'\t' -s -t column | filename.txt head head filename.txt | column -t -s $'\t'rootopen.com
linux命令:head filename.txt | column -t -s $'\t' $'\t' -s -t column | filename.txt head head filename.txt | column -t -s $'\t'rootopen.com
2018-03-10 13:40:48

Linux的Bash命令行(A-Z排序)