BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
alepage
Barite | Level 11

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.

1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

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.

 

View solution in original post

2 REPLIES 2
Tom
Super User Tom
Super User

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.

 

sas-innovate-white.png

Our biggest data and AI event of the year.

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.

 

Register now!

Creating Custom Steps in SAS Studio

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 1503 views
  • 0 likes
  • 3 in conversation