how to differentiate file and directory name using ls command


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting how to differentiate file and directory name using ls command
# 1  
Old 07-20-2012
how to differentiate file and directory name using ls command

how to differentiate file and directory name using ls command.

l
# 2  
Old 07-20-2012
have you tried using ls -l command??
# 3  
Old 07-20-2012
Code:
ls -l | grep ^d  # for directories

# 4  
Old 11-19-2012
if you use ls -l, the contents in the directory listed as below.

drwxr-xr-x 3 truesrc staff 9728 Nov 15 18:37 exercises/
-rw-r--r-- 1 truesrc staff 155 Oct 8 12:52 fibbno.cc

if entry is a directory, it starts with bit 'd'
if entry is a file,it starts with '-'
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Don't have tree, need advise to differentiate dir from file from this alternative that uses find

Hi, I don't have tree on the Solaris server and our SA don't want to install it. I found this example from One Line Linux Command to Print Out Directory Tree Listing | systemBash that more or less does what I am mainly looking for. Example run is as below: $: find ./ | sed -e... (2 Replies)
Discussion started by: newbie_01
2 Replies

2. AIX

Any file to differentiate JAVA JRE and JAVA JDK

Folks, Any idea of where can I find a specific file to differentiate JRE and Java JDK installed on AIX platform :cool: (3 Replies)
Discussion started by: dellcisco
3 Replies

3. Shell Programming and Scripting

Change to directory and search some file in that directory in single command

I am trying to do the following task : export ENV=aaa export ENV_PATH=$(cd /apps | ls | grep $ENV) However, it's not working. What's the way to change to directory and search some file in that directory in single command Please help. (2 Replies)
Discussion started by: saurau
2 Replies

4. UNIX for Dummies Questions & Answers

Preseed command to copy a file to /root directory

I was hoping to edit the command below to copy a file "start.bin" from the install cd to /root on the installation machine. d-i preseed/late_command string \ wget -O /target/root/start.bin 'http://abc.start.bin' \ && in-target chmod 755 /root/start.bin \ My best guess is it would... (0 Replies)
Discussion started by: dmunoz
0 Replies

5. Shell Programming and Scripting

Help with script or command to differentiate difference between two input file?

I got two file write now. Input file 1: >data_1 DSFDFDSGFDSGSGEGTRTRERPOYIORPGKKGDSPKFSDKFPSDKFSPFS >data_34 WEEREREWREWOIQOPIEPDSKLFNDSFNSKNCASKJHDAFHAOUDFEOWWIOUFEWIUEWIRUEWIRUEWIORUEWOREWR >data_21 ASDASDQWEQWRQERFWPOTGIUWEIPOFIOFDSNFKSJDNFSKDHFKDSJHFKDSJHF >data_4... (14 Replies)
Discussion started by: perl_beginner
14 Replies

6. Shell Programming and Scripting

command to reduce size of file/directory???

Hello, I want to compress any given file or directory. I used 1)gzip 2)zip But when I do "ls -l". I found that the zipped file is in fact greater in size than the original file. Can you please tell me the commands which will show me the difference in its size. (2 Replies)
Discussion started by: nsharath
2 Replies

7. Shell Programming and Scripting

how to differentiate columns of a file in perl with no specific delimiter

Hi everybody, This time I am having one issue in perl. I have to create comma separated file using the following type of information. The problem is the columns do not have any specific delimiter. So while using split I am getting different value. Some where it is space(S) and some where it is... (9 Replies)
Discussion started by: Amiya Rath
9 Replies

8. UNIX for Dummies Questions & Answers

differentiate between a file and a device

sorry probably a beginner question but i was just wondering how unix does this as device are treated as files? (6 Replies)
Discussion started by: keith_hampson
6 Replies

9. UNIX for Dummies Questions & Answers

file restoration to new directory - tar command

hi, i face some problem which need URGENT assistance. am performing a restoration for recovery in an AIX UNIX server. when i use the tar -tvf command to view the tape contents, it gives me /ata1/mydir/myfile. i understand that how the file was backed up determine whether we could restore... (2 Replies)
Discussion started by: newbie168
2 Replies

10. UNIX for Dummies Questions & Answers

how to differentiate a file from a folder in a FIND?

I have to read a complete folder and if it is a file older that 7 days I have to copy it elsewhere and if it is a folder nothing to make. The way I do it: for I in `find /home/. -name "*" -mtime +7` do cp -Rf $I /home/elsewhere/. done Am I okay with the way I want to do it? Help... (3 Replies)
Discussion started by: denysQC
3 Replies
Login or Register to Ask a Question