出于测试目的,我创建了以下目录。
user@linux:~$ mkdir dir0{1..3}
user@linux:~$ ls -l
total 12K
drwxr-xr-x 2 user user 4.0K Mei 31 10:45 dir01
drwxr-xr-x 2 user user 4.0K Mei 31 10:45 dir02
drwxr-xr-x 2 user user 4.0K Mei 31 10:45 dir03
user@linux:~$
然后,我用find -exec删除了它
user@linux:~$ find -type d -exec rmdir {}
我使用windows和linux混合开发我的脚本,所以我想要一种简单的方法来跟踪文件路径,而不必设置它们。
我使用的是here包,在从命令行运行之前,这个包似乎运行得很好。
我的所有文件都存储在项目目录中,所以我对外部文件没有任何问题。
举例说明。我的linux项目位于:/home/ubuntu/work/ On Windows it:c\work\
在RStudio中,当我使用here时,这两种情况都很好,所以如果我调用另一个脚本,我就使用source(here("expected_value.R")),这在两个平台上都可以使用。
当我从linux命令行的脚本运行时
Rscr
我在找一个脚本,工具...对于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
我按照以下步骤在我的Debian中安装GHDL编译器,但是现在我需要卸载这个编译器来安装x64版本,但我不能。
By downloading the binaries and unpacking them manually:
$ wget http://ghdl.free.fr/site/uploads/Main/ghdl-i686-linux-latest.tar
$ sudo tar xvf ghdl-i686-linux-latest.tar
(这将生成文件ghdl-0.29-i 686-pc-linux.tar.bz 2)
$ cd ghdl-0.29-i686-pc-lin
我需要删除Linux上的目录,它的名称超过4个字符。但是不要计算子目录的长度。
例如:
/12345/.. <= Should be deleted
/123456/.. <= Should be deleted
/1234/12345 <= Should NOT be deleted
/1234/123456 <= Should NOT be deleted
更新:得到了它:
find -maxdepth 1 -regextype posix-egrep -type d -regex '.*[^/]{4}' -exec rm -rf {}
如何在不出错的情况下在Linux上执行此搜索和替换?
$ git status
On branch main
Your branch is up to date with 'origin/main'.
nothing to commit, working tree clean
$ find . -not -path './.git' -type f -exec sed -i -e 's/old/new/g' -e 's/old2/new2/g' {} +
$ git status
fatal: unknown index en