Linux shell basic3 dd wc comm chmod ls

Generating files of any size

/dev/zerois a character special device, which infinitely returns the zero byte (\0).

The above command will create a file called junk.datathat is exactly 1MB in size. Let‘s go

through the parameters: ifstands for – inputfile, ofstands for – outputfile, bsstands for

BYTES for a block, and countstands for the number of blocks of bsspecified to be copied.

dd if=/dev/zero of=junk.data bs=1M count=1

1+0 records in

1+0 records out

1048576 bytes (1.0 MB) copied, 0.00263553 s, 398 MB/s

Comm command demo:

[[email protected] test]$ cat file1.txt file2.txt

1

2

3

4

1

2

4

5

[[email protected] test]$ comm file1.txt file2.txt

1

2

3

4

5

[[email protected] test]$ comm file1.txt file2.txt -1

1

2

4

5

[[email protected] test]$ comm file1.txt file2.txt -2

1

2

3

4

[[email protected] test]$ comm file1.txt file2.txt -3

3

5

[[email protected] test]$ comm file1.txt file2.txt -3 -1

5

-1 removes first column from output

-2 removes the second column

-3 removes the third column

[[email protected] test]$ ll

total 1052

-rw-rw-r--. 1 hadoop hadoop 99 Feb 16 08:34 all_txt_files.txt

-rw-rw-r--. 1 hadoop hadoop 8 Feb 17 03:29 file1.txt

-rw-rw-r--. 1 hadoop hadoop 8 Feb 17 03:29 file2.txt

-rw-rw-r--. 1 hadoop hadoop 1048576 Feb 17 03:20 junk.data

-rw-rw-r--. 1 hadoop hadoop 44 Feb 16 02:06 mul_bank.txt

-rw-rw-r--. 1 hadoop hadoop 30 Feb 16 08:55 num.txt

drwxrwxr-x. 2 hadoop hadoop 4096 Feb 16 03:05 sub

-rw-rw-r--. 1 hadoop hadoop 44 Feb 16 02:11 test.txt

"-"—if it is a regular file.

"d"—if it is a directory

"c"—for a character device

"b"—for a block device

"l"—if it is a symbolic link

"s"—for a socket

"p"—for a pipe

chmod u=rwx g=rw o=r filename

Here:

u =specifies user permissions

g =specifies group permissions

o =specifies others permissions

chmod a+x filename

a statnd for all.

Read,write,and execute permissions have unique octal numbers as follows:

r--=4

-w-=2

--x=1

Touch is a command that can create blank files or modify the timestamp of files if they

already exist.

Symbolic links are just pointers to other files.

ln -s targetfilename(directory) link_name

ln -s test.txt test_link.txt

Counting number of lines, words, and characters in a file

$ wc -l file # count number of lines as follows:

$ wc -w file #count words number

$ head -10 filename

$ tail -10 filename

Head used to get the first n lines of the file.

Tail is used to get the last n lines of the file.

时间: 2024-11-07 03:29:53

Linux shell basic3 dd wc comm chmod ls的相关文章

linux shell命令之wc/split及特殊字符

[时间:2018-07] [状态:Open] [关键词:linux, wc, split, 通配符,转义符,linux命令] 0 引言 整理这篇文章的目的不是为了什么学习,仅仅是为了强化下记忆,以便下次可以直接使用不用重新搜索一次了. 本文将主要整理linux shell下的命令,如果你不是在*nix系统下使用,建议无视本文. 后面内容主要包含三部分:wc.split以及shell中的特殊字符. 1 wc字符计数工具 wc命令可输出给定文件或文件列表的行数.字节数.字符数.词数以及最大行宽度(

linux Shell 中grep+wc取值在shell中的结果与手动执行结果不一致的坑

vim restart.sh #!/bin/bash VDS=ps -ef |grep -w vds|grep -v grep|wc -l if [ $VDS -eq 0 ];thencd /usr/local/program;./linux-start.sh restartelseecho "It's ok,don't restart!"fi 注:如果在shell窗口直接运行上面的变量赋值不加 -w没有问题,但在脚本里,用 sh -x restart.sh 里来看并不一致,解决方法就

Pytohn实现Linux shell中的wc命令

#!/usr/bin/python import sys import os from optparse import OptionParser    def opt():     parser = OptionParser()     parser.add_option("-c", "--char",                       dest="chars",                       action="s

linux shell ls -1 列显示文件

/******************************************************************************* * linux shell ls -1 列显示文件 * 说明: * 有时候写shell脚本的时候,经常需要将文件以一列的形式列出来,然后再进行 * for迭代,之前一般用ls+awk来做,其实ls本身就提供这个功能. * * 2016-3-16 深圳 南山平山村 曾剑锋 *********************************

linux shell wc 命令

1. 语法与选项 Short Option Long Option Option Description -c –bytes print the byte counts -m –chars print the character counts -l –lines print the newline counts   –files0-from=F read input from the files specified by NUL-terminated names in file F -L –ma

LINUX SHELL脚本攻略笔记[速查]

Linux Shell脚本攻略笔记[速查] 资源 shell script run shell script echo printf 环境变量和变量 pgrep shell数学运算 命令状态 文件描述符和重定向 cat 数组和关联数组 alias date 调试脚本 函数和参数 管道 读取命令输出 read 字段分隔符和迭代器 循环 比较和测试 find xargs tr md5sum sha1sum 对目录进行校验 sort uniq tempfile split bash变量匹配切分 exp

Linux shell脚本基础学习详细介绍(完整版)一

Linux shell脚本基础学习这里我们先来第一讲,介绍shell的语法基础,开头.注释.变量和 环境变量,向大家做一个基础的介绍,虽然不涉及具体东西,但是打好基础是以后学习轻松地前提.1. Linux 脚本编写基础◆1.1 语法基本介绍 1.1.1 开头 程序必须以下面的行开始(必须方在文件的第一行): #!/bin/sh 符号#!用来告诉系统它后面的参数是用来执行该文件的程序.在这个例子中我们使用/bin/sh来执行程序. 当编辑好脚本时,如果要执行该脚本,还必须使其可执行. 要使脚本可执

Linux Shell 运维脚本功底积累

1.删除Linux远程用户连接会话 [[email protected] logs]# w 10:45:28 up 15 days, 16:23, 4 users, load average: 0.00, 0.00, 0.00 USER TTY FROM [email protected] IDLE JCPU PCPU WHAT root tty1 - Sun21 4days 0.00s 0.00s -bash root pts/0 192.168.1.2 09:11 0.00s 0.07s 0

《Linux shell变量总结回顾》RHEL6

由于上篇文章总结的不是很详细,有很多方面并未涉及到shell各个方面,所以发表此文章对shell做了更全面的总结: 文章版权:http://www.cnblogs.com/linux-super-meng/ 环境变量路径: [[email protected] ~]# set   //查看到的是局部变量和全局变量2种 [[email protected] ~]# env  //查看系统的全局环境变量 [[email protected] ~]# echo $PATH  //查看系统环境变量路径