Hello,
I have tried to use the following find command
find -maxdepth 1 -type f /dwh_operation/sasprocess/smp_production/smp_ref/sasmacro
to get the file listing into that directory but without getting those from the subfolders.
Also, I have tried the ls command:
ls /dwh_operation/sasprocess/smp_production/smp_ref/sasmacro -l --time-style=long-iso
so, I am getting all the information on a file that I need but I am getting also subfoldername into the listing as well as the listing of the files hosted into those subfolder.
Is there a way to use the ls command to get the listing of the file only in the specify folder not those from the subfolder
Thanks in advance for you help.
I don't quite get what the question is.
If you want to limit the ls command from diving into the subdirectories use the -d option.
ls -ld /dwh_operation/sasprocess/smp_production/smp_ref/sasmacro/*
If you want to get all of the information of the ls command output from the find command there are options to do that. Look at the -printf option.
Examples:
Here is meaning of the -printf options used. %p - Filename without path. %s - Size in bytes. %Td%Tb%TY:%TT - LASTMOD in SAS DATETIME format. %T - Means use the last time file was modified. d - Day of month (01-31) b - Short month string (Jan, Feb, ...) Y - Four digit year T - Time (HH:MM:SS.sssssss) %Y - Type of the file, including following symbolic links. %M - File permissions in sybolic form (-rwxrwxrwx). %u - Name of the file owner. %g - Name of the file group. %h - Path of the file, including path specified on command line. %l - Path to the target of a symbolic link (else blank). \n - Add linefeed to end of string.
I don't quite get what the question is.
If you want to limit the ls command from diving into the subdirectories use the -d option.
ls -ld /dwh_operation/sasprocess/smp_production/smp_ref/sasmacro/*
If you want to get all of the information of the ls command output from the find command there are options to do that. Look at the -printf option.
Examples:
Here is meaning of the -printf options used. %p - Filename without path. %s - Size in bytes. %Td%Tb%TY:%TT - LASTMOD in SAS DATETIME format. %T - Means use the last time file was modified. d - Day of month (01-31) b - Short month string (Jan, Feb, ...) Y - Four digit year T - Time (HH:MM:SS.sssssss) %Y - Type of the file, including following symbolic links. %M - File permissions in sybolic form (-rwxrwxrwx). %u - Name of the file owner. %g - Name of the file group. %h - Path of the file, including path specified on command line. %l - Path to the target of a symbolic link (else blank). \n - Add linefeed to end of string.
You need to use a maxdepth of 0 to stay in the root directory of your search.
Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.
Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.
Check out this tutorial series to learn how to build your own steps in SAS Studio.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.