Horje
a) Write a shell script to list all of the directory files in a directory. Code Example
a) Write a shell script to list all of the directory files in a directory.
# !/bin/bash
echo "enter directory name"
read dir
if[ -d $dir]
then
echo "list of files in the directory"
ls –l $dir|egrep ‘^d’
else
echo "enter proper directory name"
fi
bash how to print the list of files in a directory
# Basic syntax:
ls /path/to/directory/

# Example usage 1:
ls /path/to/directory/ > output_file.txt # Write the files to an output
# Example usage 2:
ls /path/to/directory/ | grep *.txt > output_file.txt # Write the subset
# of files that match the grep search (e.g. end in .txt)




Shell

Related
godaddy ssl integration to the ubuntu apache Code Example godaddy ssl integration to the ubuntu apache Code Example
Ubuntu 20.04 install nginx Code Example Ubuntu 20.04 install nginx Code Example
enable ssh linux Code Example enable ssh linux Code Example
remove trailing slash from nginx Code Example remove trailing slash from nginx Code Example
What is the command to open a file from within Emacs? Code Example What is the command to open a file from within Emacs? Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
11