ls 排序

首先我们通过man 来看看 ls其中有几项;

  • -S     sort by file size : 按大小降序

–sort=WORD

sort by WORD instead of name: none -U, extension -X, size -S, time -t, version -v

–time=WORD

with -l, show time as WORD instead of modification time: atime -u, access -u, use -u, ctime -c, or status -c; use specified time as sort key if –sort=time

–time-style=STYLE

with -l, show times using style STYLE: full-iso, long-iso, iso, locale, +FORMAT. FORMAT is interpreted like ‘date’; if FORMAT is FORMAT1<newline>FORMAT2, FORMAT1

applies to non-recent files and FORMAT2 to recent files; if STYLE is prefixed with ‘posix-’, STYLE takes effect only outside the POSIX locale

  • -t     sort by modification time 按时间升序
  • -u     with -lt: sort by, and show, access time with -l: show access time and sort by name otherwise: sort by access time  以文件上次被访问的时间排序。
  • -U     do not sort; list entries in directory order 不做排序
  • -v     natural sort of (version) numbers within text 
  • -X     sort alphabetically by entry extension 

ls -lS    按大小降序

ls -l | sort -n -k5     按大小升序

ls -lrt   按时间降序

ls -lnt    按时间升序

ls -l | sort -k9    按文件名升序(这是ls的默认输出方式)

ls -lr 按文件名降序

ls -l | sort -rk9   按文件名降序

附:

ls对当前目录和文件大小排序

du -s * | sort -nr

只对当前目录排序,并用直观的大小显示出来

for i in $(ls -l |grep ‘^d’ |du -s * |sort -nr|awk ‘{print $2}’);do du -sh $i;done

Vi 中文乱码

Vi ~/.vimrc 添加以下内容

set fileencodings=utf-8,ucs-bom,gb18030,gbk,gb2312,cp936

set termencoding=utf-8

set encoding=utf-8

xcode 手工下载安装模拟器runtime

原文地址

Install and manage Simulator runtimes from the command line

Download the Simulator runtime you want to install from the Apple Developer website. Then follow these steps with the command line to install it:

  1. Select a version of Xcode.
  2. Run the first launch experience to install the required system components, including simctl.
  3. Install the Simulator runtime with simctl.

simctl verifies the signature of the downloaded Simulator runtime, and then installs it in a secure location on your computer.

For example:

 xcode-select -s /Applications/Xcode-beta.app  

 xcodebuild -runFirstLaunch   

 xcrun simctl runtime add “~/Downloads/watchOS 9 beta Simulator Runtime.dmg”

Tip

To learn more about additional runtime management features, run xcrun simctl runtime.

To download and install all the platforms that the Xcode version you selected supports, use the -downloadAllPlatforms option on xcodebuild.

    xcodebuild -downloadAllPlatforms

To download and install Simulator runtimes for a specific platform, use the -downloadPlatform option and specify the platform.

清理mac 启动台图标

1、sqlite3数据库位置

/private/var/folders/73/w1gsct654151mgqzf218d8qh0000gn/0/com.apple.dock.launchpad/db

2、读取db文件

sqlite3  dbfile

3、查看表

.tables

4、查看表结构

select * from sqlite_master where type=”table” and name=’apps’

5、Sql 操作

如何查看crontab的日志记录

在Unix和类Unix的操作系统之中,crontab命令常用于设置周期性被执行的指令,也可以理解为设置定时任务。

crontab中的定时任务有时候没有成功执行,什么原因呢?这时就需要去日志里去分析一下了,那该如何查看crontab的日志记录呢?

1. linux

看 /var/log/cron.log这个文件就可以,可以用tail -f /var/log/cron.log观察

2. unix

在 /var/spool/cron/tmp文件中,有croutXXX001864的tmp文件,tail 这些文件就可以看到正在执行的任务了。

3. mail任务

在 /var/spool/mail/root 文件中,有crontab执行日志的记录,用tail -f /var/spool/mail/root 即可查看最近的crontab执行情况。

腾讯云图