sed变量 引号

在使用sed对日志或者其它文本进行parse的过程当中,有时候我们需要引用外部变量的值,

或者获取一个shell命令执行的结果,以便达到更加可观的输出结果。这里介绍如何做到。

sed中使用变量替换

1.sed命令使用双引号的情况下,使用$var直接引用

$ echo|sed “s/^/$RANDOM.rmvb_/g” 

29328.rmvb_ 

# 上面例子引用了一个环境变量$RANDOM的值

2.sed命令使用单引号的情况下,使用'”$var”‘引用

类似,我们可以看到

$ echo|sed ‘s/^/'”$RANDOM”‘.rmvb_/g’ 

31338.rmvb_

sed中执行外部命令

1.sed命令使用单引号的情况下使用’`shell command`’或者’$(shell command)’引用命令执行的结果

还是以上面案例分析,例子如下

$ echo|sed ‘s/^/’`echo $RANDOM`’.rmvb_/g’ 

8063.rmvb_ 

# 上面的例子使用了旧式的命令替换,也可以采用新式的命令替换方法,如下

$ echo|sed ‘s/^/’$(echo $RANDOM)’.rmvb_/g’ 

18554.rmvb_ 

# 下面例子取用当前日期作为结果的一部分,如下

$ echo|sed ‘s/^/’$(date +”%Y%m%d”)’.rmvb_/g’ 

20120108.rmvb_ 

2.sed命令使用双引号的情况下直接`shell command`或者$(shell command)引用命令执行的结果 

类似的,双引号的情况,如下

$ echo|sed “s/^/$(date +”%Y%m%d”).rmvb_/g” 

20120108.rmvb_ 

# 使用环境变量$RANDOM以及旧式命令替换的例子

$ echo|sed “s/^/`echo $RANDOM`.rmvb_/g” 

4988.rmvb_

总结

在sed语句里面,变量替换或者执行shell命令,双引号比单引号少绕一些弯子

awk 设置输入输出分隔符

awk  F=”\t” ‘{OFS=”:”;print $1,$2}’

最后如果只写print 相当于print $0,意思是输出这些文本,未使用分隔符,“,”表示使用分隔符,使用OFS定义的分隔符

解决nfs挂载错误wrong fs type, bad option, bad superblock

错误:
[root@localhost]# mount -t nfs 192.168.0.106:/home/nfs1 /home/nfs
mount: wrong fs type, bad option, bad superblock on 192.168.0.106:/home/nfs1,
missing codepage or helper program, or other error
(for several filesystems (e.g. nfs, cifs) you might
need a /sbin/mount. helper program)
In some cases useful info is found in syslog – try
dmesg | tail or so

解决办法:
1 apt-get install nfs-common
或者
1 yum install nfs-utils

Svn 和git 同时使用

已经是git仓库情况

1、svn checkout

2、svn status 查看状态,会有许多删除冲突

3、使用revert命令恢复 svn revert ./* -R [或者单独文件 R递归]

4、再次查看状态,删除冲突消失

5、git pull ,git reset –hard 清除svn的更改,然后查看git 和svn状态是否正常,

6、修改,往两处提交就可以了

此过程可能需要多次gc cleanup

1 Svn checkout

2 git pull

3 换行符问题

4 git 修改为 autocrlf

5 Add 提示有些lf转换问题

6 再改为autocrlf false

7 再次add

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.