在本文中,我们将给您介绍关于在Unix中使用Less转到特定的行号的详细内容,并且为您解答unixless怎么用的相关问题,此外,我们还将为您提供关于awk–选择特定的行号、bash–如何将不以特定模
在本文中,我们将给您介绍关于在 Unix 中使用 Less 转到特定的行号的详细内容,并且为您解答unix less 怎么用的相关问题,此外,我们还将为您提供关于awk – 选择特定的行号、bash – 如何将不以特定模式开头的行连接到UNIX中的上一行?、Excel根据下拉菜单跳转到特定的列/单元格、iOS – 将特定的UIViewController锁定到特定方向的知识。
本文目录一览:- 在 Unix 中使用 Less 转到特定的行号(unix less 怎么用)
- awk – 选择特定的行号
- bash – 如何将不以特定模式开头的行连接到UNIX中的上一行?
- Excel根据下拉菜单跳转到特定的列/单元格
- iOS – 将特定的UIViewController锁定到特定方向
在 Unix 中使用 Less 转到特定的行号(unix less 怎么用)
我有一个大约有百万行的文件。我需要去第 320123 行查看数据。我怎么做?
答案1
小编典典作为n
行号:
ng
: 跳转到第 n 行。默认是文件的开头。nG
: 跳转到第 n 行。默认是文件的结尾。
因此,要转到第 320123 行,您需要输入320123g
.
直接从维基百科复制粘贴。
awk – 选择特定的行号
提前谢谢了.
解决方法
awk 'NR%100==0' inputfile
See it
bash – 如何将不以特定模式开头的行连接到UNIX中的上一行?
它可以用shell脚本中的循环完成,但我很难得到一个awk / sed一个衬垫.
SampleFile.txt
These are leaves. These are branches. These are greenery which gives oxygen,provides control over temperature and maintains cleans the air. These are tigers These are bears and deer and squirrels and other animals. These are something you want to kill Which will see you killed in the end. These are things you must to think to save your tomorrow.
期望的输出
These are leaves. These are branches. These are greenery which gives oxygen,provides control over temperature and maintains cleans the air. These are tigers These are bears and deer and squirrels and other animals. These are something you want to kill Which will see you killed in the end. These are things you must to think to save your tomorrow.
解决方法
awk 'BEGIN {accum_line = "";} /^These/{if(length(accum_line)){print accum_line; accum_line = "";}} {accum_line = accum_line " " $0;} END {if(length(accum_line)){print accum_line; }}' < data.txt
代码由三部分组成:
>标记为BEGIN的块先于其他任何操作执行.它对全局初始化很有用>标记为END的块在常规处理完成时执行.包装好东西很好.就像打印最后收集的数据一样,如果这行在开头没有这些(这种情况)>其余的是为每一行执行的代码.首先,搜索模式并完成相关的事情.其次,无论字符串内容如何,都会进行数据收集.
Excel根据下拉菜单跳转到特定的列/单元格
您链接到的问题具有所需基本内容。您可以使用Application.Match
查找日期的第一个实例,然后使用Application.Goto
滚动到日期。
Private Sub Worksheet_Change(ByVal Target As Range)
Dim dropDownRange As Range
Set dropDownRange = Me.Range("B11")
'// Check if the change is happening in your dropdown cell
If Not Intersect(Target,dropDownRange) Is Nothing Then
Dim lookInRange As Range
Set lookInRange = Me.Range("F9:UA9")
Dim matchResult As Variant
matchResult = Application.Match(CLng(dropDownRange.Value),lookInRange,0)
'// First check that the corresponding date was found
If Not IsError(matchResult) Then
Application.Goto lookInRange.Cells(matchResult),Scroll:=True
End If
End If
End Sub
在工作表代码模块中添加以下代码:
如果要滚动到第1行,则可能是以下内容:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim dropDownRange As Range
Set dropDownRange = Me.Range("B11")
'// Check if the change is happening in your dropdown cell
If Not Intersect(Target,0)
'// First check that the corresponding date was found
If Not IsError(matchResult) Then
Dim matchRange As Range
Set matchRange = lookInRange.Cells(matchResult)
Application.Goto Me.Cells(1,matchRange.Column),Scroll:=True
End If
End If
End Sub
iOS – 将特定的UIViewController锁定到特定方向
我正在使用UINavigationController来推送UIViewController,我希望UIViewController仅在UIInterfaceOrientationLandscapeRight中,但是当我旋转手机时,它会切换回其他方向.
-(BOOL)shouldAutorotate{ return NO; } -(NSUInteger)supportedInterfaceOrientations{ return UIInterfaceOrientationLandscapeRight; } -(UIInterfaceOrientation)preferredInterfaceOrientationForPresentation{ return UIInterfaceOrientationLandscapeRight; }
解决方法
并将此添加到您想要仅显示横向的viewcontroller.
-(void)viewDidAppear:(BOOL)animated{ [[UIDevice currentDevice] setValue: [NSNumber numberWithInteger: UIInterfaceOrientationLandscapeLeft] forKey:@"orientation"]; }
实际上,这是来自类似问题的解决方案.
How to force view controller orientation in iOS 8?
今天关于在 Unix 中使用 Less 转到特定的行号和unix less 怎么用的讲解已经结束,谢谢您的阅读,如果想了解更多关于awk – 选择特定的行号、bash – 如何将不以特定模式开头的行连接到UNIX中的上一行?、Excel根据下拉菜单跳转到特定的列/单元格、iOS – 将特定的UIViewController锁定到特定方向的相关知识,请在本站搜索。
本文标签: