我有这样一个文件(邮件日志):
Feb 22 23:53:39 info postfix[102]: connect from APVLDPDF01[...
Feb 22 23:53:39 info postfix[101]: BA1D7805A1: client=APVLDPDF01[...
Feb 22 23:53:39 info postfix[103]: BA1D7805A1: message-id
Feb 22 23:53:39 info opendkim[139]: BA1D7805A1: DKIM-Signature field added
我不太明白下面的if-语句实际上做了什么,从条件输出可能是什么的意义上说:
if linux-command-1 | linux-command-2 | linux-command-3 > /dev/null
我的理解是:
Linux 1被执行,它的输出被管道传输到2作为输入.
Linux 2用LC1的输入执行,它的输出被管道传输到3中.
Linux 3使用LC2的输入执行,它的输出被重定向到/dev/null,基本上不会出现。
,但是实际的if语句呢?是什么让它变得真实或错误呢?
为了进一步说明,下面是一个实际命令的示例:
if ps ax | grep -v gr
当我使用grep查找我需要的文本时,它将显示包含与给定模式匹配的行。
例如,
# grep -r ".*Linux" *
path0/output.txt:I hope you enjoyed working on Linux.
path1/output1.txt:Welcome to Linux.
path2/output2.txt:I hope you will have fun with Linux.
然后,我想编辑文件path2/output2.txt,因此,我输入了vim path2/output2.txt。
但是,我不认为这是一个有效的方法。
如何在grep之后复制
我们总是可以通过使用alias命令来查看alias值。
wolf@linux:~$ alias al='grep "$1" file.txt'
wolf@linux:~$ alias al
alias al='grep "$1" file.txt'
wolf@linux:~$
不幸的是,grep不能使用别名。不知道是什么问题。如果你知道问题和解决办法,请告诉我。
wolf@linux:~$ al
random text
abc def jkl
random text
abc ghi jkl
random text
wolf@li
在这两个for语句中,我都得到了以下错误:
./count_files.sh: line 21: [: too many arguments
./count_files.sh: line 16: [: too many arguments.
有人能帮我吗?
#!/bin/bash
files=($(find /usr/src/linux-headers-3.13.0-34/include/ -type f -name '[aeiou][a-z0-9]*.h'))
count=0
headerfiles=($(find /usr/src/linux-headers-3.
我在找一个脚本,工具...对于linux,它可以找到所有文件和所有文件中的关键字,类似于OSX Finder (我不是在寻找具有相同Finder界面的应用程序,而只是相同的工作)
例如,如果我在OSX Finder中搜索"linux“,我会得到:
linux (directory with linux name)
linux-2.4.0 (directory with linux in name)
...
memory.h (file with linux in text)
...
command.c (file with linux in text)
...
so-08-filesy
# ldd /usr/bin/ffmpeg
linux-vdso.so.1 => (0x00007ffffc1fe000)
libavfilter.so.0 => not found
libpostproc.so.51 => not found
libswscale.so.0 => not found
libavdevice.so.52 => not found
libavformat.so.52 => not found
libavcodec.so.52 => not found
li
我和我的合作伙伴在使用这个基本的Linux脚本时遇到了麻烦。我们的讲师把一个高级的Linux脚本包扔给我们去调试,我们都很迷茫。脚本应该删除文件名中包含嵌入空格的文件,而我使用的是实际的rm命令。我得到了“缺少操作数”,我不确定该怎么办。
#!/bin/bash
# This script is supposed to delete all filenames in current directory
#+ containing embedded spaces.
# It doesn't work
# Why not?
badname= ls | grep " "