我的网站将有多个部分,每个部分我打算可以调整大小.为了实现这一点,我制定了一个"可调整大小"的指令,例如:
<div class="workspace" resize="full" ng-style="resizeStyle()">
<div class="leftcol" resize="left" ng-style="resizeStyle()">
Run Code Online (Sandbox Code Playgroud)
使用类似于以下内容的指令:
lwpApp.directive('resize', function ($window) {
return {
scope: {},
link: function (scope, element, attrs) {
scope.getWinDim = function () {
return {
'height': window.height(),
'width': window.width()
};
};
// Get window dimensions when they change and return new element dimensions
// based on attribute
scope.$watch(scope.getWinDim, function (newValue, oldValue) {
scope.resizeStyle = function () {
switch (attrs.resize) {
case 'full':
return {
'height': newValue.height,
'width': (newValue.width - dashboardwidth)
};
case 'left':
return …
Run Code Online (Sandbox Code Playgroud) 我知道sed
可以通过几种不同的方式附加文本:
附加字符串NEW_TEXT
:
sed -i '/PATTERN/ a NEW_TEXT' file
Run Code Online (Sandbox Code Playgroud)附加文件内容file_with_new_text
:
sed -i '/PATTERN/ r file_with_new_text' file
Run Code Online (Sandbox Code Playgroud)但是,无论如何要sed
通过stdout 追加文本管道吗?我希望得到相当于:
# XXX,YYY,ZZZ are line numbers
# The following appends lines XXX-YYY in file1
# after line ZZZ in file2.
sed 'XXX,YYY p' file1 > /tmp/file
sed -i 'ZZZ r /tmp/file' file2
Run Code Online (Sandbox Code Playgroud)
无需使用临时文件.这可能吗?