unix

sql的日期格式化转化

会有一股神秘感。 提交于 2020-02-29 18:39:21
1. DATE_FORMAT() 函数用于以不同的格式显示日期/时间数据。 Sql代码 DATE_FORMAT( date,format) 可以使用的格式有: 格式 描述 %a 缩写星期名 %b 缩写月名 %c 月,数值 %D 带有英文前缀的月中的天 %d 月的天,数值(00-31) %e 月的天,数值(0-31) %f 微秒 %H 小时 (00-23) %h 小时 (01-12) %I 小时 (01-12) %i 分钟,数值(00-59) %j 年的天 (001-366) %k 小时 (0-23) %l 小时 (1-12) %M 月名 %m 月,数值(00-12) %p AM 或 PM %r 时间,12-小时(hh:mm:ss AM 或 PM) %S 秒(00-59) %s 秒(00-59) %T 时间, 24-小时 (hh:mm:ss) %U 周 (00-53) 星期日是一周的第一天 %u 周 (00-53) 星期一是一周的第一天 %V 周 (01-53) 星期日是一周的第一天,与 %X 使用 %v 周 (01-53) 星期一是一周的第一天,与 %x 使用 %W 星期名 %w 周的天 (0=星期日, 6=星期六) %X 年,其中的星期日是周的第一天,4 位,与 %V 使用 %x 年,其中的星期一是周的第一天,4 位,与 %v 使用 %Y 年,4 位 %y 年,2 位 实例

编程哲学=UNIX编程哲学

五迷三道 提交于 2020-02-29 16:49:05
非常喜欢<UNIX编程艺术>上写到的几点,让我又有信心了(这不是说我已经开始学UNIX了;-P): * 让每个程序就做好一件事. 如果有新任务就重新开始,不要往原程序中加入新功能而搞复杂. * 对拙劣代码别犹豫,扔掉重写. * 文本流是最通用的接口. * 花哨的算法在n很小时通常很慢. * 数据压倒一切. 如果你已经选择了正确的数据结构并且把一切都组织得井井有条,正确的算法也就不言自明. 编程的核心是数据结构,而不是算法. * 雕琢之前先要有原形,跑之前先学会走. (意思是不要急着搞优化) * 透明性是指你一眼就能看出软件是在做什么以及怎样做的. * 保证软件健壮性的一个相当重要的策略就是避免在代码中出现特例. * 把知识叠入数据以求逻辑质朴而健壮. * 用简单指针就能完成的任务,在其他任务中,往往不得不用更复杂的过程才能完成. (恩!) * 通俗原则. 最易用的程序就是用户需要学习新东西最少的程序. * 要良好地运用UNIX哲学,你就应该不断追求卓越. 你必须相信,软件设计是一门技艺,值得你付出所有的智慧,创造力和激情. 否则,你的实现就不会超越那些简单,老套的设计与实现. ... 你需要用心,需要去游戏,需要乐于探索. 但是还没完全理解简洁,通俗和健壮的方法. 但以后编程不会再只为了实现功能而满足了,垃圾的东西就坚决扔掉. 来源: https://www.cnblogs.com

How to create a list of topics in Apache Kafka using single command

我怕爱的太早我们不能终老 提交于 2020-02-28 15:43:27
问题 As of now I am creating a topic one by one by using below command. sh ./bin/kafka-topics --create --zookeeper localhost:2181 --topic sdelivery --replication-factor 1 --partitions 1 Since I have 200+ topics to be created. Is there any way to create a list of topic with a single command? I am using 0.10.2 version of Apache Kafka. 回答1: This seems like more of a unix/bash question than a Kafka one: the xargs utility is specifically designed to run a command repeatedly from a list of arguments. In

k8s centos

泪湿孤枕 提交于 2020-02-28 13:30:23
https://www.2cto.com/net/201905/810399.html 问题描述 安装完docker后,执行docker相关命令,出现 ”Got permission denied while trying to connect to the Docker daemon socket at unix: // /var/ run /docker.sock: Get http:/ /%2Fvar%2Frun%2Fdocker.sock/ v1. 26 /images/ json: dial unix /var/ run /docker.sock: connect: permission denied“ 原因 摘自docker mannual上的一段话 Manage Docker as a non-root user The docker daemon binds to a Unix socket instead of a TCP port. By default that Unix socket is owned by the user root and other users can only access it using sudo. The docker daemon always runs as the root user. If you don’t want

C Primer Plus(第五版)1

筅森魡賤 提交于 2020-02-28 03:44:48
这是C Primer Plus(第五版)的第一章,上传上来主要是方便我进行做笔记,写注释,还有我会删掉一些“废话”等。 1.1 C语言的起源 贝尔实验室的 Dennis Ritchie 在1972年开发了C,当时他正在与Ken Thompson 一起设计 UNIX操作系统 。 1.4 计算机工作的基本原理 现代计算机可分为几个部件。中央处理单元(或称CPU)担负着绝大部分的计算工作,随机访问存储器(或称RAM)作为一个工作区来保存程序和文件;永久存储器,一般是硬盘,即使在计算机关机时也能记下程序和文件;还有各种外围设备(如键盘,鼠标和监视器)用来提供人与计算机之间的通信。CPU负责处理程序,所以我们集中来讨论它的功能。 CPU 的工作非常简单,至少在我们所做的这一简短的描述中是这样的。它从内存中获取一个指令并执行该指令,然后从内存中获取下一个指令并执行,。一个千兆 CPU 可以在一秒种内进行大约一亿次这样的操作,所以 CPU 能以惊人的速度来从事其枯燥的工作。CPU 有自己的小工作区,该工作区由若干个寄存器(registers)组成,每个寄存器可以保存一个数。一个寄存器保存下一条指令的内存地址,CPU 使用该信息获取下一条指令。获取一条指令后,CPU 在另一个寄存器中保存该指令并将第一个寄存器的值更新为下一条指令的地址。CPU 只能理解有限的指令(指令集)。还有

linux / unix进程的峰值内存使用情况

↘锁芯ラ 提交于 2020-02-27 21:11:08
是否有一个工具可以运行命令行并报告峰值RAM使用总量? 我在想象类似于/ usr / bin / time的东西 #1楼 Valgrind单线: valgrind --tool=massif --pages-as-heap=yes --massif-out-file=massif.out ./test.sh; grep mem_heap_B massif.out | sed -e 's/mem_heap_B=\\(.*\\)/\\1/' | sort -g | tail -n 1 注意使用--pages-as-heap来测量进程中的所有内存。 更多信息: http : //valgrind.org/docs/manual/ms-manual.html #2楼 如果进程运行至少几秒钟,那么您可以使用以下bash脚本,它将运行给定的命令行,然后打印到stderr峰值RSS(替换 rss 您感兴趣的任何其他属性)。 它有点轻量级,它适用于我使用Ubuntu 9.04中包含的 ps (我不能说 time )。 #!/usr/bin/env bash "$@" & # Run the given command line in the background. pid=$! peak=0 while true; do sleep 1 sample="$(ps -o rss= $pid 2>

在UNIX中grep一个选项卡

南笙酒味 提交于 2020-02-27 09:01:39
如何在Unix平台上的文件中 grep tab(\\ t)? #1楼 答案更简单。 写你的grep并在引用类型中选项卡键,它至少在ksh中运行良好 grep " " * #2楼 一个很好的选择是使用'sed as grep'(如本经典的 sed教程中所述 )。 sed -n 's/pattern/&/p' file 示例(适用于bash,sh,ksh,csh,..): [~]$ cat testfile 12 3 1 4 abc xa c a c\2 1 23 [~]$ sed -n 's/\t/&/p' testfile xa c a c\2 [~]$ sed -n 's/\ta\t/&/p' testfile a c\2 #3楼 如果使用GNU grep,您可以使用Perl样式的正则表达式: grep -P '\t' * #4楼 一种方法是(这是与Bash) grep -P '\t' -P 打开Perl正则表达式,因此\\ t将起作用。 正如用户 放松 所说,它可能是特定于GNU grep。 如果shell,编辑器或终端允许,可以选择在其中插入一个选项卡。 #5楼 使用gawk,将字段分隔符设置为tab(\\ t)并检查字段数。 如果超过1,则有/是标签 awk -F"\t" 'NF>1' file 来源: oschina 链接: https://my.oschina.net

Windows等效的Unix tail命令[关闭]

☆樱花仙子☆ 提交于 2020-02-27 05:47:31
我正在寻找相当于Unix'tail'的命令,它允许我在写入时查看日志文件的输出。 #1楼 Windows资源工具包工具 包中提供了 tail 命令和许多其他命令。 #2楼 任何对使用批处理命令的 DOS CMD尾部感兴趣的人(见下文)。 这不是完美的,有时会重复。 用法:tail.bat -d tail.bat -f -f @echo off SETLOCAL ENABLEEXTENSIONS ENABLEDELAYEDEXPANSION rem tail.bat -d <lines> <file> rem tail.bat -f <file> rem ****** MAIN ****** IF "%1"=="-d" GOTO displayfile IF "%1"=="-f" GOTO followfile GOTO end rem ************ rem Show Last n lines of file rem ************ :displayfile SET skiplines=%2 SET sourcefile=%3 rem *** Get the current line count of file *** FOR /F "usebackq tokens=3,3 delims= " %%l IN (`find /c /v "" %sourcefile

Bash: grep pattern from command output

点点圈 提交于 2020-02-26 08:12:39
问题 I'm really new with bash, but it's one of the subjects on school. One of the exercises was: Give the line number of the file "/etc/passwd" where the information about your own login is. Suppose USERNAME is my own login ID, I was able to do it perfectly in this way: cat /etc/passwd -n | grep USERNAME | cut -f1 Which simply gave the line number required (there may be a more optimised way). I wondered however, if there was a way to make the command more general so that it uses the output of

Bash: grep pattern from command output

妖精的绣舞 提交于 2020-02-26 08:12:28
问题 I'm really new with bash, but it's one of the subjects on school. One of the exercises was: Give the line number of the file "/etc/passwd" where the information about your own login is. Suppose USERNAME is my own login ID, I was able to do it perfectly in this way: cat /etc/passwd -n | grep USERNAME | cut -f1 Which simply gave the line number required (there may be a more optimised way). I wondered however, if there was a way to make the command more general so that it uses the output of