我在找一个脚本,工具...对于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
在我的目录层次结构中,我有许多名为STATUS.txt的文本文件。这些文本文件每个包含一个关键字,如完整、等待、未来或打开。我希望执行以下形式的shell命令:
./mycommand OPEN
,它将列出包含名为STATUS.txt的文件的所有目录,其中该文件包含文本“打开”。
将来,我希望扩展这个脚本,以便对返回的目录进行排序。排序将由存储在与PRIORITY.txt相同目录中的文件STATUS.txt的数值决定。然而,这可以等到我的能力水平提高。目前,我很高兴按任何顺序列出目录。
我搜索了Stack溢出,但没有结果:
unix按文件内容筛选
linux按文件内容过滤
she
在这两个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.
我们总是可以通过使用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
我和我的合作伙伴在使用这个基本的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 " "
我有一个Linux shell脚本,输出如下(名称和分数字段长度是可变的,字段由空格分隔):
Name Gender Age Score
John Smith M 24 1110
Alice Darby F 30 2220000
test = [('John Smith','M',24,1110),('Alice Darby','F',30,2220000)]
有没有更好的方法呢?
我有两个主要问题:
当我打开Synaptic时,它说包linux-image-5.3.0-26-generic坏了。我试图使用按钮Fix破坏包修复它,并删除它。但它给了我这样的信息:
E: linux-image-5.3.0-26-generic: installed linux-image-5.3.0-26-generic package pre-removal script subprocess returned error exit status 1``
我尝试了在其他答案中看到的一些控制台命令,但它们没有工作:
$ sudo apt install -f
E: Could not g
我不太明白下面的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
如果我将cat命令保存到字符串中,然后执行它,那么我将得到一个错误。
linux# cmd="cat /data/test/test.tx* | grep toto"
linux# eval '$cmd'
cat: |: No such file or directory
cat: grep: No such file or directory
cat: toto: No such file or directory
即使是
linux# $cmd
cat: |: No such file or directory
cat: grep: No such file
几天前,我试着安装0ad,一个游戏,通过终端。在终端完成之前,我意外地关闭了它,现在我无法在我的机器上安装或更新任何程序。我跑了13.10。
我已经尝试搜索并找到了很多关于这个错误的文章、帖子和讨论,但是我还没有找到一个修复它的方法。
我试过跑步
sudo apt-get clean && sudo apt-get autoremove
哪种输出
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following package
我必须在子目录中安装一些.deb包,即/opt/corbos-linux/2.4.4/sysroots/x86_64-pokysdk-linux/。此文件夹应用作新的根目录。我试着安装这些软件包
dpkg --root=/opt/corbos-linux/2.4.4/sysroots/x86_64-pokysdk-linux/ -i *.deb
但是这个错误出现了:
dpkg: error: unable to access dpkg status area: No such file or directory
而如果我给
dpkg --instdir=/opt/corbos-linux/2.
当我使用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之后复制