小编and*_*čič的帖子

bash 脚本中的 exit 0、exit 1 和 exit 2 是什么意思?

我正在做一些练习练习。

编写一个脚本,该脚本将给出一个月份数字作为参数,并将该数字转换为月份名称。结果将打印到标准输出。

我做了一个解决方案:

# Test for number of argument

if [ "$#" -eq 0 ] ; 
then
  echo -e "No argument."
  echo -e "Write a number between 1 and 12."
  exit 1
elif [ "$#" -gt 1 ] ;
then
  echo -e "More than 1 argument."
  echo -e "Write a number between 1 and 12."
  exit 1
else
  numb=$1
  case "$numb" in
    1) echo "Month: January";;
    2) echo "Month: February";;
    3) echo "Month: March";;
    4) echo "Month: April";;
    5) echo …
Run Code Online (Sandbox Code Playgroud)

bash scripts

82
推荐指数
3
解决办法
35万
查看次数

在 bash 脚本中,如何转到名称存储在变量中的目录?

我正在做一个 FileCreator 脚本:

#!/bin/bash

echo "Welcome to the file creator! Please type the directory name:"
read dirName

mkdir $dirName

#Now I want to change directory to that new $dirName that will be run from Terminal.
Run Code Online (Sandbox Code Playgroud)

我现在的问题是,如何更改dirName终端上可见的这个新目录的路径。所以,最后,路径应该是:/home/my_user_name/SCRIPTS/dirName当我运行这个脚本时......

拜托,只是一个建议?:)

command-line bash scripts directory

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

我想将所有pdf文件复制到另一个目录中

Linux用户!我遇到了一个问题:我在 directory 中有所有 pdf 文件Downloads,但我希望它复制 subfolder 中的所有文件\Download\BOOKS\。我将如何使用for循环复制所有文件?

for files in ...

copy

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

标签 统计

bash ×2

scripts ×2

command-line ×1

copy ×1

directory ×1