unix

How to transfer binary file in SFTP?

放肆的年华 提交于 2020-01-23 06:43:11
问题 How to transfer binary file in SFTP? Will it be same as normal file? Or is there any different process? 回答1: A binary file is a normal file. You are possibly referring to a text/ascii vs. a binary transfer mode, known from an FTP protocol. The FTP protocol defaults to the text/ascii mode, so one usually had to ensure that the mode was switched to the binary not to corrupt the transferred binary files. SFTP protocol also supports a text/ascii vs. binary mode distinction in its newer versions.

MySQL Galera node not starting (aborting with Error 'WSREP: […]: 60: failed to reach primary view: 60 (Operation timed out)')

馋奶兔 提交于 2020-01-23 06:16:11
问题 I am trying to setup three Galera nodes on FreeBSD 10 with MySQL 5.6.26 and VirtualBox. When I set up everything and run MySQL, it exits after some time and cannot start properly. Here is my log: 2015-10-22 15:23:24 9402 [Note] WSREP: Read nil XID from storage engines, skipping position init 2015-10-22 15:23:24 9402 [Note] WSREP: wsrep_load(): loading provider library '/usr/local/lib/libgalera_smm.so' 2015-10-22 15:23:24 9402 [Note] WSREP: wsrep_load(): Galera 3.5(rXXXX) by Codership Oy <info

How to get yesterday and day before yesterday in linux?

一世执手 提交于 2020-01-23 04:35:08
问题 I want to get sysdate -1 and sysdate -2 in variable and echo it. I am using below query which gives todays date as output. #! /bin/bash tm=$(date +%Y%d%m) echo $tm How to get yesterday and day before yesterdays date? 回答1: Here is another one way, For yesterday, date -d '-1 day' '+%Y%d%m' For day before yesterday, date -d '-2 day' '+%Y%d%m' 回答2: Yesterday date YES_DAT=$(date --date=' 1 days ago' '+%Y%d%m') Day before yesterdays date DAY_YES_DAT=$(date --date=' 2 days ago' '+%Y%d%m') For any

How to use grep command on zip files

我只是一个虾纸丫 提交于 2020-01-23 04:19:09
问题 I want to grep for today's date from zip file. How can do this? I have a zip file called sen2616.z I want to get all the data for today's date 09.02.2014 回答1: Please use zipgrep . zgrep is for gz files, not for zip files. 回答2: In my case zgrep didn't work on a normal .zip file. I had to use zipgrep instead. 回答3: You can use zgrep to get what you want, with: zgrep '09.02.2014' myfile.zip See man zgrep for more info. 来源: https://stackoverflow.com/questions/25624801/how-to-use-grep-command-on

How do I pipe comm outputs to a file?

蓝咒 提交于 2020-01-23 03:27:26
问题 I've used the comm command to compare two files, but I'm unable to pipe it to a third file: comm file1 file2 > file3 comm: file 1 is not in sorted order comm: file 2 is not in sorted order How do I do this? The files are sorted already. (comm file1 file2 works and prints it out) sample input: file1: 21 24 31 36 40 87 105 134 ... file2: 10 21 31 36 40 40 87 103 ... comm file1 file2: works comm file1 file2 > file3 comm: file 1 is not in sorted order comm: file 2 is not in sorted order 回答1: You

How do I pipe comm outputs to a file?

和自甴很熟 提交于 2020-01-23 03:27:07
问题 I've used the comm command to compare two files, but I'm unable to pipe it to a third file: comm file1 file2 > file3 comm: file 1 is not in sorted order comm: file 2 is not in sorted order How do I do this? The files are sorted already. (comm file1 file2 works and prints it out) sample input: file1: 21 24 31 36 40 87 105 134 ... file2: 10 21 31 36 40 40 87 103 ... comm file1 file2: works comm file1 file2 > file3 comm: file 1 is not in sorted order comm: file 2 is not in sorted order 回答1: You

How to execute a UNIX command in Python script

北战南征 提交于 2020-01-23 02:43:12
问题 #!/usr/bin/python import os import shutil import commands import time import copy name = 'test' echo name I have a simple python scripts like the above. When I attempt to execute it I get a syntax error when trying to output the name variable. 回答1: You cannot use UNIX commands in your Python script as if they were Python code, echo name is causing a syntax error because echo is not a built-in statement or function in Python. Instead, use print name . To run UNIX commands you will need to

前端学PHP之日期与时间

雨燕双飞 提交于 2020-01-23 00:30:01
前面的话   在Web程序开发时,时间发挥着重要的作用,不仅在数据存储和显示时需要日期和时间的参与,好多功能模块的开发,时间通常都是至关重要的。网页静态化需要判断缓存时间、页面访问消耗的时间需要计算、根据不同的时间段提供不同的业务等都离不开时间。PHP为我们提供了强大的日期和时间处理功能,通过内置的时间和日期函数库,不仅能够得到PHP程序在运行时所在服务器中的日期和时间,还可以对它们进行任意检查和格式化,以及在不同格式之间进行转换等。本文将详细介绍PHP中的日期和时间   [注意]关于javascript的日期和时间相关内容请 移步至此 时间戳   UNIX时间戳是保存日期和时间的一种紧凑简洁的方法,是大多数UNIX系统中保存当前日期和时间的一种方法,也是在大多数计算机语言中表示日期和时间的一种标准格式。UNIX时间戳是从1970年1月1日0点(UTC/GMT的午夜)开始起到当前时间所经过的秒数   因为UNIX时间戳是一个32位的数字格式,所以特别适用于计算机处理,例如计算两个时间点之间相差的天数。另外,由于文化和地区的差异,存在不同的时间格式,以及时区的问题。所以,UNIX时间戳也是根据一个时区进行标准化而设计的一种通用格式,并且这种格式可以很容易地转换为任何格式   也因为UNIX时间戳是一个32位的整数表示的,所以在处理1902年以前或2038年以后的事件,将会遇到一些问题

Turn simple C program into server using netcat

我与影子孤独终老i 提交于 2020-01-22 21:23:29
问题 One cool feature of netcat is how it can turn any command line program into a server. For example, on Unix systems we can make a simple date server by passing the date binary to netcat so that it's stdout is sent through the socket: netcat -l -p 2020 -e date Then we can invoke this service from another machine by simply issuing the command: netcat <ip-address> 2020 Even a shell could be connected ( /bin/sh ), although I know this is highly unrecommended and has big security implications.

Changing the case of a string with awk

一曲冷凌霜 提交于 2020-01-22 18:33:27
问题 I'm an awk newbie, so please bear with me. The goal is to change the case of a string such that the first letter of every word is uppercase and the remaining letters are lowercase. (To keep the example simple, "word" is defined here as strictly alphabetic characters; all others are considered separators.) I learned a nice way to make the first letter of every word uppercase from another post on this website using the following awk command: echo 'abce efgh ijkl mnop' | awk '{for (i=1;i <= NF;i