小编Mic*_*mes的帖子

重命名目录中的文件的 Bash 脚本

我正在尝试编写一个脚本,该脚本将目录作为命令行参数并遍历目录中的文件,将它们的扩展名更改为.bu.

我认为这会奏效,但我得到了输出 '.bu' is not a target directory

#!/bin/bash

for  f in $1; do
  mv "$f".* .bu
done
Run Code Online (Sandbox Code Playgroud)

bash scripts

5
推荐指数
2
解决办法
6万
查看次数

尝试在 ubuntu 上安装 yeoman 以与 nodejs 和 npm 一起使用

使用 Ubuntu 13.10

我正在尝试使用 yeoman 安装,sudo npm install -g yo但它似乎不能在全局范围内工作npm并且nodejs已安装,但是,我不确定它们是否已正确安装以供全局使用。我不能使用npm我必须使用sudo npm

安装我使用的节点js

    $ sudo apt-get install python-software-properties
    $ sudo apt-add-repository ppa:chris-lea/node.js
    $ sudo apt-get update
    $ sudo apt-get install nodejs
Run Code Online (Sandbox Code Playgroud)

当我使用sudo npm install -g yo输出时,我得到的是

    /usr/bin/yo -> /usr/lib/node_modules/yo/cli.js

    > yo@1.2.1 postinstall /usr/lib/node_modules/yo
    > node ./scripts/doctor

    [Yeoman Doctor] Everything looks alright!

    yo@1.2.1 /usr/lib/node_modules/yo
    ??? is-root@0.1.0
    ??? fullname@0.1.1
    ??? opn@0.1.2
    ??? async@0.9.0
    ??? shelljs@0.3.0
    ??? lodash@2.4.1
    ??? multiline@0.3.4 (strip-indent@0.1.3)
    ??? sudo-block@0.4.0 …
Run Code Online (Sandbox Code Playgroud)

nodejs npm 13.10

4
推荐指数
1
解决办法
1万
查看次数

使用sed从文件中删除等号

我正在尝试使用 sed 从此文件中删除等号并将其通过管道传输到新文件:

I am a file to be edited.
A unique file with my own words.
T=h=e=r=e a=r=e i=s=s=u=e=s w=i=t=h t=h=i=s l=i=n=e
Run Code Online (Sandbox Code Playgroud)

我试过了,cat FixMeWithSed.txt | sed 's/=//' > FileFixedWithSed.txt但它只替换了第一个等号。

I am a file to be edited.
A unique file with my own words.
Th=e=r=e a=r=e i=s=s=u=e=s w=i=t=h t=h=i=s l=i=n=e
Run Code Online (Sandbox Code Playgroud)

我不知道如何选择所有等号,而不仅仅是第一个。谢谢!

sed

3
推荐指数
1
解决办法
7450
查看次数

标签 统计

13.10 ×1

bash ×1

nodejs ×1

npm ×1

scripts ×1

sed ×1