cat

shell脚本之centos批量创建用户

对着背影说爱祢 提交于 2019-12-02 18:23:06
操作环境:centos7 执行命令: cat /etc/passwd | grep zcl #确认没有zcl相关用户; mkdir -p /zcl/shell/    #创建脚本存放目录; cd /zcl/shell/      #切换至脚本目录; #编辑批量创建用户脚本; echo " #!/bin/bash" groupadd zcl_group for user in zcl1 zcl2 zcl3; do   useradd -G zcl_group $user;   echo "123456" | passwd -stdin $user; done >batch_useradd.sh chmod 750 ./batch_useradd.sh #修改脚本权限 ./batch_useradd.sh    #执行脚本 cat /etc/group    #查看用户组 cat /etc/passwd    #查看用户是否添加成功 来源: https://www.cnblogs.com/chalon/p/11757494.html

每天一个linux命令:cat(10)

北城余情 提交于 2019-12-02 17:08:05
cat cat命令 的用途是连接文件或标准输入并打印。这个命令常用来显示文件内容,或者将几个文件连接起来显示,或者从标准输入读取内容并显示,它常与重定向符号配合使用 注意:当文件较大时,文本在屏幕上迅速闪过(滚屏),用户往往看不清所显示的内容。因此,一般用more等命令分屏显示。为了控制滚屏,可以按Ctrl+S键,停止滚屏;按Ctrl+Q键可以恢复滚屏。按Ctrl+C(中断)键可以终止该命令的执行,并且返回Shell提示符状态 格式 cat [选项] [参数] ​ 参数选项 参数 备注 -A --show-all 等价于 -vET -b --number-nonblank 对非空输出行编号 -e 等价于 -vE -E --show-ends 在每行结束处显示 $ -n --number 对输出的所有行编号,由1开始对所有输出的行数编号 -s --squeeze-blank 有连续两行以上的空白行,就代换为一行的空白行 -t 与 -vT 等价 -T --show-tabs 将跳格字符显示为 ^I -v, --show-nonprinting 使用 ^ 和 M- 引用,除了 LFD 和 TAB 之外 实例 同时显示文件ml和m2的内容 命令: cat myFile1 myFile2 [root@VM_0_9_centos ~]# cat myFile1 my name is

你好 世界

£可爱£侵袭症+ 提交于 2019-12-02 15:24:14
!/usr/bin/python3 ftp:文件传输协议,使用应用层tcp协议,监听在tcp协议的21端口。 C/S架构,两种连接方式,命令连接(文件管理命令(比如cat),始终在线连接(持续连接)),数据连接(数据传输(上传下载),按需创建及关闭连接(临时创建,不用拆除)) --------------------------------------------------------------------------- NameError Traceback (most recent call last) <ipython-input-13-0a9ee61a125b> in <module> ----> 1 ls /etc/fstab NameError: name 'etc' is not defined 来源: https://www.cnblogs.com/hao-ran/p/11751709.html

How do I read the first line of a file using cat?

◇◆丶佛笑我妖孽 提交于 2019-12-02 14:11:11
How do I read the first line of a file using cat ? Carl Norum You don't need cat . head -1 file will work fine. You don't, use head instead. head -n 1 file.txt There are many different ways: sed -n 1p file head -n 1 file awk 'NR==1' file You could use cat file.txt | head -1 , but it would probably be better to use head directly, as in head -1 file.txt . This may not be possible with cat . Is there a reason you have to use cat ? If you simply need to do it with a bash command, this should work for you: head -n 1 file.txt cat alone may not be possible, but if you don't want to use head this

Unwanted line break using echo and cat

陌路散爱 提交于 2019-12-02 14:01:19
问题 I'm trying to add a line at the beginning of a file, using echo 'time/F:x1:x2' | cat - file.txt>newfile.txt But this produces line breaks at each line in the new file (except for after the added 'time/F:x1:x2' line). Any ideas on how to avoid this? 回答1: Use -n to disable the trailing newline: echo -n 'time/F:x1:x2' | cat - file.txt > newfile.txt There are other ways, too: sed '1s|^|time/F:x1:x2|' file.txt > newfile.txt 回答2: How about { echo 'time/F:x1:x2'; cat file.txt; } >newfile.txt or sed

java.lang.Runtime exception “Cannot run program”

限于喜欢 提交于 2019-12-02 13:31:26
I am getting an exception like java.io.IOException: Cannot run program cat /home/talha/* | grep -c TEXT_TO_SEARCH": error=2, No such file or directory while executing the command below despite that there are no issues when I execute the same command through the terminal. I need to execute and return the output of the command below: cat /home/talha/* | grep -c TEXT_TO_SEARCH Here is the method used to execute commands using Runtime class: public static String executeCommand(String command) { StringBuffer output = new StringBuffer(); Process p; try { p = Runtime.getRuntime().exec(command); p

Unix cat function (cat * > merged.txt) in Python? [duplicate]

这一生的挚爱 提交于 2019-12-02 12:28:01
This question already has an answer here: Reproduce the Unix cat command in Python 6 answers Is there a way to use the cat function from Unix in Python or something similar once a directory has been established ? I want to merge files_1-3 together into merged.txt I would usually just find the directory in Unix and then run cat * > merged.txt file_1.txt file_2.txt file_3.txt merged.txt user2390183 As we know we are going to use "Unix" cat command (unless you are looking for a pythonic way or being performance concious) You can use import os os.system("cd mydir;cat * > merged.txt") or as pointed

how to insert ctrl+d into my linux script?

女生的网名这么多〃 提交于 2019-12-02 08:08:06
I want to make the following commands: cat > template.txt [enter in the terminal] text [Ctrl+d in the terminal] in a script. Is there a way to tell the script to do enter\Ctrl d? Is there a way to create a file and write to it in script? I didn't find anything that worked for me. Thanks. A Here Document is kind of like a script version of what you're talking about, I think, although it is not entirely clear to me from your description. #!/bin/bash cat > template.txt <<- EOF Here is some text. EOF Ctrl-D itself is the EOF character, ASCII 4. When you want an interactieve user enter lines and

linux系统版本查询命令

梦想与她 提交于 2019-12-02 08:00:06
1、# uname -a (Linux查看版本当前操作系统内核信息) 2、# cat /proc/version (Linux查看当前操作系统版本信息) 3、# cat /etc/issue 或cat /etc/redhat-release(Linux查看版本当前操作系统发行版信息) 4、# cat /proc/cpuinfo (Linux查看cpu相关信息,包括型号、主频、内核信息等) 5、# getconf LONG_BIT (Linux查看版本多少位) 6、# lsb_release -a​ 来源: CSDN 作者: 王腾腾 链接: https://blog.csdn.net/aibreaking213/article/details/79202293