Detailed explanation of how to obtain the names of all folders in a certain directory using Shell under Linux

黄舟
Release: 2017-05-28 11:38:19
Original
4721 people have browsed it

This article mainly introduces linux Shell to obtain the names of all folders in a directory. Friends who need it can refer to

to view all files under the directory:

#!/bin/bash
cd /目标目录
for file in $(ls *)
do
  echo $file
done
Copy after login

Extension method, view all directories under the directory

#!/bin/bash
cd /export/bak/original_document
for dir in $(ls split*)
do
  [ -d $dir ] && echo $dir #先判断是否是目录,然后再输出
done
Copy after login

The above is the detailed content of Detailed explanation of how to obtain the names of all folders in a certain directory using Shell under Linux. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!