从任何目录递归调用bash脚本

author author     2023-03-23     624

关键词:

This snippet determines the path and script name that will need to be called, and then calls that script and passes it parameters.
  1. #!/usr/bin/env bash
  2.  
  3. #this script calls for three variables to be passed to it, a directory, an indent amount, and a file for output.
  4.  
  5. script_dir="$( cd "$( dirname "$BASH_SOURCE[0]" )" && pwd )"
  6. script_name=$(basename "$0")
  7. path_to_script=$script_dir/$script_name
  8.  
  9. new_indent="$indent " #this increases the indent amount for the next recursion
  10. new_start_dir="$start_dir/$directoryname" #this sets the next directory
  11. $("$path_to_script" "$new_start_dir" "$new_indent" "$outfile") #this actually calls the same
  12. #script with the updated parameters

以相反的顺序递归重命名目录,Bash脚本

】以相反的顺序递归重命名目录,Bash脚本【英文标题】:Recursivelyrenamedirectoryinreverseorder,Bashscript【发布时间】:2013-06-2913:34:35【问题描述】:如何递归重命名目录结构?类似Batchrenamedirectoriesinreverseorder但一个简单的班轮??我... 查看详情

Bash 脚本:递归更改文件权限

...2017-10-2301:23:03【问题描述】:我需要一个Bash脚本来更改目录和所有子目录中所有文件的文件权限。它的行为应该是这样的:foreachfileindirectory(andsubdirectories)ifiamtheownerofthefileifitisadirect 查看详情

用于在没有 -R 的 FTP 服务器上列出递归目录的 Bash 脚本

】用于在没有-R的FTP服务器上列出递归目录的Bash脚本【英文标题】:BashscriptforrecursivedirectorylistingonFTPserverwithout-R【发布时间】:2015-05-0700:16:25【问题描述】:FTP服务器上有多个带有子文件夹和图像文件的文件夹。-R被禁用。我需... 查看详情

如何从脚本本身中获取 Bash 脚本的源目录?

】如何从脚本本身中获取Bash脚本的源目录?【英文标题】:HowcanIgetthesourcedirectoryofaBashscriptfromwithinthescriptitself?【发布时间】:2010-09-0818:17:52【问题描述】:我如何获取Bash脚本所在目录的路径,inside该脚本?我想使用Bash脚本作... 查看详情

如何从脚本本身中获取 Bash 脚本的源目录?

】如何从脚本本身中获取Bash脚本的源目录?【英文标题】:HowcanIgetthesourcedirectoryofaBashscriptfromwithinthescriptitself?【发布时间】:2010-09-0818:17:52【问题描述】:我如何获得Bash脚本所在目录的路径,inside该脚本?我想使用Bash脚本作... 查看详情

如何从脚本本身中获取 Bash 脚本的源目录?

】如何从脚本本身中获取Bash脚本的源目录?【英文标题】:HowcanIgetthesourcedirectoryofaBashscriptfromwithinthescriptitself?【发布时间】:2010-09-0818:17:52【问题描述】:我如何获取Bash脚本所在目录的路径,inside该脚本?我想使用Bash脚本作... 查看详情

被另一个bash脚本调用后获取文件的当前目录[重复]

】被另一个bash脚本调用后获取文件的当前目录[重复]【英文标题】:Getcurrentdirectoryoffileaftergettingcalledbyanotherbashscript[duplicate]【发布时间】:2013-05-2620:19:16【问题描述】:所以我有一个bash脚本,它调用另一个bash脚本。第二个脚本... 查看详情

Bash 脚本:如何确保脚本在使用“或”(||) 条件调用的函数中出现任何错误时退出?

...:如何确保脚本在使用“或”(||)条件调用的函数中出现任何错误时退出?【英文标题】:Bashscripting:Howtoensurescriptexitsonanyerrorinfunctioncalledwithan"or"(||)condition?【发布时间】:2019-08-1023:55:17【问题描述】:这是一个示例脚本... 查看详情

如何从调用 bash 的 Tcl 脚本验证密码?

】如何从调用bash的Tcl脚本验证密码?【英文标题】:HowtoauthenticatepasskeyfromaTclscriptcallingbash?【发布时间】:2011-03-0206:11:23【问题描述】:我有一个tcl脚本,它从bash调用很多函数,包括ssh。我正在努力的部分如下所示:procconnectwhe... 查看详情

从 bash shell 脚本调用 Python 脚本 [重复]

】从bashshell脚本调用Python脚本[重复]【英文标题】:CallPythonscriptfrombashshellscript[duplicate]【发布时间】:2019-10-3111:36:28【问题描述】:我正在尝试实现一个命令,该命令涉及将POST/GET请求发送到远程服务器并解释JSON格式结果。由于... 查看详情

用于搜索目录并将文件移动到新目录、删除任何副本的 Bash 脚本

】用于搜索目录并将文件移动到新目录、删除任何副本的Bash脚本【英文标题】:Bashscriptforsearchingdirectoryandmovingfilestoanewdirectory,deletinganycopies【发布时间】:2014-04-0913:23:21【问题描述】:我有一个2TB的硬盘驱动器,里面装满了备... 查看详情

如何从 Mac 上的 bash 脚本调用 ./snowsql 文件?

】如何从Mac上的bash脚本调用./snowsql文件?【英文标题】:Howtocall./snowsqlfilefromabashscriptonMac?【发布时间】:2019-12-1821:48:16【问题描述】:我正在尝试从bash脚本建立连接,完成类似于以下的操作:rmcguigan$snowsql--filenametest.sql*SnowSQL*v... 查看详情

从 C# Windows 窗体内部调用的 Bash 脚本

】从C#Windows窗体内部调用的Bash脚本【英文标题】:BashScriptcalledfrominsideC#WindowsForms【发布时间】:2022-01-1714:14:05【问题描述】:我正在尝试从Windows窗体应用程序中运行bash脚本。我的代码如下所示://CommandStringstringflashNVS="c:\\\\msys... 查看详情

text从脚本本身获取bash脚本的源目录(代码片段)

查看详情

如何在bash中递归复制所有目录和文件?

】如何在bash中递归复制所有目录和文件?【英文标题】:Howtocopyinbashalldirectoryandfilesrecursive?【发布时间】:2011-12-2417:24:23【问题描述】:我有脚本:find./SourceFolder/-maxdepth4-execcp-R\'\'./DestFolder/\\;SourceDir还包含子文件夹。问题在于... 查看详情

如何从 haskell 程序调用 bash 或 shell 脚本?

】如何从haskell程序调用bash或shell脚本?【英文标题】:Howtoinvokebashorshellscriptsfromahaskellprogram?【发布时间】:2012-05-1904:18:59【问题描述】:我正在用我在gitbash中运行的haskell编写一些shell脚本,但是我希望能够从这些脚本中使用其... 查看详情

使用 Git Bash 从 Shell 脚本调用批处理脚本

】使用GitBash从Shell脚本调用批处理脚本【英文标题】:CallBatchScriptfromShellScriptusingGitBash【发布时间】:2015-05-1703:30:53【问题描述】:我有一个批处理脚本(master.bat),它调用了许多批处理脚本。Master.bat:calla.batcallb.batcallc.bat调... 查看详情

从 cronjob 运行 bash 脚本失败并显示“没有这样的文件或目录”

】从cronjob运行bash脚本失败并显示“没有这样的文件或目录”【英文标题】:Runningabashscriptfromacronjobfailswith"Nosuchfileordirectory"【发布时间】:2018-01-2608:55:36【问题描述】:我正在尝试运行以下bash脚本,该脚本在激活conda环... 查看详情