简体   繁体   English

每次我更改bashrc目录时列出所有文件的脚本?

[英]Script to list all files each time I change directory for bashrc?

I would like to list all files each time I execute the "change directory" command. 我想在每次执行“更改目录”命令时列出所有文件。

I have already tried adding this to my ~/.bashrc: 我已经尝试将其添加到我的〜/ .bashrc中:

function cdl { cd $1; ls;} 

and running this in terminal: 并在终端中运行它:

cdl directorytoswitchto

Long story short: I would like to do cd and ls in the same command. 长话短说:我想在同一命令中执行cdls

To override a builtin function with a different version, you typically will call the original via command . 要使用其他版本覆盖内置函数,通常会通过command调用原始函数。 For example, 例如,

cd() { command cd "$@" && ls; }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用bashrc函数更改为文件目标目录? - How can I change to the file destination directory using a bashrc function? 如何使用bash脚本列出Linux目录中的所有文件? - How do I list all files in a directory in Linux using bash script? 列出目录(和子目录)中的所有文件(带完整路径),按访问时间排序 - List all files (with full paths) in a directory (and subdirectories), order by access time Shell Script,将每 2 个文件移动到每个目录 - Shell Script, move each 2 files to each directory 我为什么要跑。 〜/ .bashrc每次我想访问我的快捷方式? - Why must I run . ~/.bashrc each time I want to access my shortcuts there? .bashrc 中的 shopt -s extdebug 在脚本文件中不起作用 - shopt -s extdebug in .bashrc not working in script files bash - 找到所有.bashrc文件并附加到它们 - bash - find all .bashrc files and append to them 我想使用 shell 脚本删除目录下的所有文件,将文件目录作为参数传递 - I want to delete all the files under a directory using shell script, passing file directory as an argument 一个 bash 脚本,它将目录中所有文件的创建时间与存储在变量中的时间戳进行比较 - A bash script that will compare the creation time of all files in a directory to a timestamp stored in a variable bash脚本重命名目录中的所有文件? - bash script to rename all files in a directory?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM