file command usage


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers file command usage
# 1  
Old 04-25-2005
file command usage

Hi, i would like to determine how many shell scripts are in a directory. Someone recommended me the file command, but i don't know how to use it in that way.
anybody???
Thanks!!!
# 2  
Old 04-25-2005
? You don't know how to use it? Did you read the man page on the file command? It should give you exactly what you want.

Hint - use * in place of file name
# 3  
Old 04-25-2005
i wanted to count the number of shell scripts in a directory.
I think i got it with:
file *.sh | wc -l

what if a shell script isn't ended with .sh?
is there any way to know it with the file command?

thanks
# 4  
Old 04-25-2005
You REALLY need to read the man page for the 'file' command. Do that, run the command ( file * ), and then ask questions if you still don't understand.
# 5  
Old 04-25-2005
sorry!

i solved it with:
file * | grep shell script | wc -l
# 6  
Old 04-25-2005
Quote:
Originally Posted by kfad
sorry!

i solved it with:
file * | grep shell script | wc -l

Above works only if you have an assumption that every script in the current directory has magic line. (#!/usr/bin/someshell)
# 7  
Old 04-26-2005
and if it doesn't? how would i know?
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Usage of '.' in MV command

Hi, Could you please let me know, why we should not use '.' in move command, if we use it, is it something wrong.. Please share the details on it. /home/rahualux/emp.csv /home/rahualux/details/employee_files/. Or other example for mutlipile files /home/rahualux/*.csv... (3 Replies)
Discussion started by: rahualux
3 Replies

2. Solaris

SunOS 5.5.1 usage of Makefile command in make file

I am new to Solaris and compilation using make files. I have a code base which is organized into different folders. At the root folder is a master make file and in the sub directories, there are make files for that particular folder. In the make files present in subdirectories, I am seeing... (2 Replies)
Discussion started by: rajujayanthy
2 Replies

3. UNIX for Dummies Questions & Answers

Sort command usage

I have one file like this: NEW /ifs/SQL_Backups3/SQL_SharePoint1 NEW /ifs/SQL_Backups/SQL_SharePointThis can be easily sorted by the following command: cat file| sort -k3,3nBut I have another file like this: /Pool0/local/Benchmark /Pool0/local/CRAD /Pool0/local/crdhw/espresso_scratch1... (5 Replies)
Discussion started by: newbie2010
5 Replies

4. UNIX for Dummies Questions & Answers

Usage of find command

I need to find a file that has been modified in last 3-4 hours. mtime tells us about file modified in n days. Is there any way I can check for hours or minutes file modified or created before. (5 Replies)
Discussion started by: ankush_mehra
5 Replies

5. Shell Programming and Scripting

cp -v command usage?

I am trying to output a log file from cp usage. I think this can be achieved. In my code I have this. cp -i -v ~/files/* ~/backups/oldfiles/;; > ~/logs/logfile.logThe error I get is "syntax error near unexpected token '>' What am I missing? (7 Replies)
Discussion started by: gameinn
7 Replies

6. UNIX for Dummies Questions & Answers

Command to display the space usage (memory usage) of a specific directory.

Hi all, Can you please tell me the command, with which one can know the amount of space a specific directory has used. df -k . ---> Displays, the amount of space allocated, and used for a directory. du -k <dir name> - gives me the memory used of all the files inside <dir> But i... (2 Replies)
Discussion started by: abhisheksunkari
2 Replies

7. AIX

How to monitor the IBM AIX server for I/O usage,memory usage,CPU usage,network..?

How to monitor the IBM AIX server for I/O usage, memory usage, CPU usage, network usage, storage usage? (3 Replies)
Discussion started by: laknar
3 Replies

8. Shell Programming and Scripting

grep command usage

what is the grep command to get the second occurence of pattern in a file or how to do with sed ? (1 Reply)
Discussion started by: santosh1234
1 Replies

9. HP-UX

how can I find cpu usage memory usage swap usage and logical volume usage

how can I find cpu usage memory usage swap usage and I want to know CPU usage above X% and contiue Y times and memory usage above X % and contiue Y times my final destination is monitor process logical volume usage above X % and number of Logical voluage above can I not to... (3 Replies)
Discussion started by: alert0919
3 Replies

10. UNIX for Dummies Questions & Answers

Disk Usage in GB and Unix command to find the biggest file/folder

Hi All, Please help me out 1) Command to find the disk usage in GB. I know that du -k will give in kilobites. 2) How to find the Biggest file/folder in a given set of files/folders. Thanks in advance Regards, Manas (8 Replies)
Discussion started by: manas6
8 Replies
Login or Register to Ask a Question