标签: command

用于在 shell 脚本上显示注释的简单命令

假设您有以下脚本:

# My comment line 1
# My comment line 2
# My comment line 3

echo "My script"
cd $MY_PATH
./anotherScript.ksh
Run Code Online (Sandbox Code Playgroud)

是否有任何命令可以显示:

# My comment line 1
# My comment line 2
# My comment line 3
Run Code Online (Sandbox Code Playgroud)

或者,我可以编写一个脚本来检测第一块注释。

谢谢

linux shell command comments

0
推荐指数
1
解决办法
8477
查看次数

perl 像在 c shell 中一样嵌入数据

有没有办法将数据嵌入到 perl 脚本中,然后以类似于 c-shell 的方式作为临时文件使用/读取它。

cat<< eof>tmp.txt
store a multiline text file
eof

run_some_function on [anotherexternalfile] with [tmp.txt]

rm tmp.txt
Run Code Online (Sandbox Code Playgroud)

我想在一个 perl 脚本中嵌入多组命令/数据文件来包装一组命令,以避免需要过多的外部命令文件。

更新

嵌入的文件/数据需要作为另一个可执行函数的输入文件读取,如下所示。

system("executable.exe [anotherexternalfile] [tmp.txt]");
Run Code Online (Sandbox Code Playgroud)

embed shell perl command

0
推荐指数
1
解决办法
708
查看次数

Maven命令需要跳过下载依赖

我有一个 maven 项目,如果我尝试进行 mvn 测试,它会在每 12 小时后下载依赖项。如果文件已经存在,我是否可以跳过下载依赖项。我的目的是减少花费的时间并减少网络带宽的使用。

shell command-line command maven

0
推荐指数
1
解决办法
3011
查看次数

Shell 子命令输出到父命令

我有一个单行命令,让我们说

grep needle haystack.file
Run Code Online (Sandbox Code Playgroud)

如果我想使用 pwd 命令用当前工作目录替换“needle”怎么办。现在可能可以使用管道,但我需要针部分来显示工作目录和命令的其余部分是相同的。

所以最好是这样的:

grep (pwd) haystack.file
Run Code Online (Sandbox Code Playgroud)

执行时实际上会运行以下命令:

grep /var/www/html/ haystack.file
Run Code Online (Sandbox Code Playgroud)

我做了一些搜索,发现了很多带有管道的例子,但它不能应用于我的场景,因为第一部分 (grep) 和第二部分 (haystack.file) 在应用程序中是固定的。

bash shell command pipe

0
推荐指数
2
解决办法
3312
查看次数

Bash - 在if语句中找不到命令错误

我在第14行和第16行遇到问题,其中有嵌套的if语句.它返回命令未找到错误,但我测试了那部分代码,它可以在其他地方使用.

#passing the argument page page.html
cat $1 | grep -o "wp-cli.org/commands/cache/\w*/\"" > temp.txt
#creating all pdf files
for i in $(cat temp.txt)
do 
source=$(echo $i | grep -o -P "wp-cli.org/commands/cache/\w+")
dest=$(echo $i | grep -o -P "\w+/\"" | grep -o -P "\w+")
#echo $source $dest
wkhtmltopdf $source $dest".pdf"
pdfCount=$(ls *pdf | wc -l)
echo $pdfCount
if [ ! -f sample.pdf ]
then
 if [$pdfCount -eq 1] 
 then
    firstPdf=$dest".pdf" 
 fi
 if [$pdfCount -eq 2]
 then
    pdfunite $firstPdf $dest".pdf" sample.pdf
 fi …
Run Code Online (Sandbox Code Playgroud)

bash command if-statement

0
推荐指数
1
解决办法
2532
查看次数

列出所有使用NUnit控制台运行程序的测试

在NUnit控制台运行程序中,有一个控制台命令用于列出Visual Studio项目中的所有测试。有人知道吗?

我使用版本3.6.1。

c# nunit command nunit-console

0
推荐指数
1
解决办法
1334
查看次数

在Perl中发送linux命令 - Grep管道传输到grep

基本代码:

my $ContentDate = `date -d '1 hour ago' '+%Y-%m-%e %H:'`;
my $Fail2banNo = `grep Ban /var/log/fail2ban.log | grep $ContentDate | wc -l`;

if (($Fail2banNo > $fail2ban)) {

} else {

}
Run Code Online (Sandbox Code Playgroud)

为什么Perl不会正确完成这些命令?$ fail2ban已经定义为0,所以这不是问题.

fail2ban.log确实包含一个应匹配的行(当从shell运行命令时它匹配):

2018-07-19 xx:11:50,200 fail2ban.actions[3725]: WARNING [iptables] Ban x.x.x.x
Run Code Online (Sandbox Code Playgroud)

我一直得到的错误是:

grep: 10:: No such file or directory
sh: -c: line 1: syntax error near unexpected token `|'
sh: -c: line 1: ` | wc -l'
Argument "" isn't numeric in numeric gt (>) at /usr/local/bin/tmgSupervision.pl line 3431. …
Run Code Online (Sandbox Code Playgroud)

linux perl grep command pipe

0
推荐指数
1
解决办法
139
查看次数

如何使用bash命令输出不带冒号的日期

我想输出以下内容:

命令:

日期+%T *

01:49:14
Run Code Online (Sandbox Code Playgroud)

但是如何在没有冒号的情况下显示它呢?我正在使用bash命令。

bash command date

0
推荐指数
1
解决办法
328
查看次数

use word under cursor in cscope search

Is there a way to use the word under the cursor in a cscope search in Vim? If the cursor is over a variable Foo and I want to avoid needing to type Foo again in the command line but would like to assemble :cs f s Foo.

Is there any way I can automate it?

vim command shortcut cscope

0
推荐指数
1
解决办法
35
查看次数

Linux“猫”如何解码文件?

我想知道Linux如何cat解码文件。假设它是一个英文文本文件,该命令似乎使用ASCII解码,但是如何cat解码随机文件呢?

linux command ascii decode utf-8

0
推荐指数
1
解决办法
45
查看次数

标签 统计

command ×10

shell ×4

bash ×3

linux ×3

perl ×2

pipe ×2

ascii ×1

c# ×1

command-line ×1

comments ×1

cscope ×1

date ×1

decode ×1

embed ×1

grep ×1

if-statement ×1

maven ×1

nunit ×1

nunit-console ×1

shortcut ×1

utf-8 ×1

vim ×1