Sponsored Content
Top Forums Shell Programming and Scripting count file(s) under a specific directory Post 67221 by muthukumar on Tuesday 22nd of March 2005 01:41:47 AM
Old 03-22-2005
Quote:
Originally Posted by leemjesse
How do I count number of file in a directory. Here is what I want to do.

1. find total number of file in a directory in variable total
IF you want to have only regular files in the current directory without system files like .shell_profile, .sheel_history,.. .ssh then,

Code:
count=$(ls -l | awk '/^-/ { print $9 }')

If you want to have all files then,
Code:
count=$(ls -la | awk '/^-/ { print $9 }')

Quote:
Originally Posted by leemjesse
2. ftp all the file


3. ftp_return_code=`grep -c "Transfer complete" $logfile`

if [$total == ftp_return_code]

then
exit 0

else

exit -1
fi
If you go for rcp / scp then it will be very easy to check return_code and transfer files one by one.

With ftp it will get more complex to check return code that, check and trasfer will be needed as one by one.

HTH.
 

10 More Discussions You Might Find Interesting

1. HP-UX

count occurences of specific character in the file

For counting the occurences of specific character in the file I am issuing the command grep -o 'character' filename | wc -w It works in other shells but not in HP-UX as there is no option -o for grep. What do I do now? (9 Replies)
Discussion started by: superprogrammer
9 Replies

2. Shell Programming and Scripting

Count specific character(s) very large file

I'm trying to count the number of 2 specific characters in a very large file. I'd like to avoid using gsub because its taking too long. I was thinking something like: awk '-F' { t += NF - 1 } END {print t}' infile > outfile which isn't working Any ideas would be great. (3 Replies)
Discussion started by: dcfargo
3 Replies

3. Shell Programming and Scripting

How to extract specific data and count number containing sets from a file?

Hello everybody! I am quit new here and hope you can help me. Using an awk script I am trying to extract data from several files. The structure of the input files is as follows: TimeStep parameter1 parameter2 parameter3 parameter4 e.g. 1 X Y Z L 1 D H Z I 1 H Y E W 2 D H G F 2 R... (2 Replies)
Discussion started by: Daniel8472
2 Replies

4. UNIX for Advanced & Expert Users

allow user to use sudo cp on a specific directory and only a specific file

Is there a way to allow a user to use sudo cp on a specific directory and only a specific file? (6 Replies)
Discussion started by: cokedude
6 Replies

5. Shell Programming and Scripting

how to count how many subdirectory containing more than a certain number of specific file type

hi I want to write a script which count the number of subdirectories in the current root directory that contain more than a specified number of files of a specific type. Is there an easy way to do this? Thanks Robert (2 Replies)
Discussion started by: piynik
2 Replies

6. UNIX for Dummies Questions & Answers

How do I count how many times a specific word appear in a file (ksh)?

Hi Please can you help how do I count the number of specific characters or words that appear in a file? (8 Replies)
Discussion started by: fretagi
8 Replies

7. Shell Programming and Scripting

Shell scripting-I need a script which should watch a directory for a file with specific directory

I need a script which should watch a directory for a file with specific directory. If it finds a file in directory, it should search for few specific keyword in the file. if the keyword exists, it should trim string from specific column. The file should be moved to another directory and the a... (8 Replies)
Discussion started by: akashdeepak
8 Replies

8. UNIX for Dummies Questions & Answers

To count total of specific character in a file and save its value to a variable

Hi all, I have a file that contains characters. How do I get total of spesific character from that file and save the count to a variable for doing for calculation. data.txt 1 2 2 2 2 3 3 4 5 6 7 8 5 4 3 4 (5 Replies)
Discussion started by: weslyarfan
5 Replies

9. Shell Programming and Scripting

Count specific character of a file in each line and delete this character in a specific position

I will appreciate if you help me here in this script in Solaris Enviroment. Scenario: i have 2 files : 1) /tmp/TRANSACTIONS_DAILY_20180730.txt: 201807300000000004 201807300000000005 201807300000000006 201807300000000007 201807300000000008 2)... (10 Replies)
Discussion started by: teokon90
10 Replies

10. UNIX for Advanced & Expert Users

Searching for file types by count in specific folder in RHEL 6

So I'm trying to search for the top 10 or 15 items under a directory by file type. I want to run a command on a directory and get something like the following: Example of expected output.. .PDF: 100, .txt: 95, .word: 80.. What would be the best way of going about this? I've searched around... (2 Replies)
Discussion started by: shackle101
2 Replies
srf_info(1)							   Staden io_lib						       srf_info(1)

NAME
srf_info - Lists information about the contents of an SRF file SYNOPSIS
srf_info [-l bitmap] srf_archive ... DESCRIPTION
srf_info lists some simple frequency metrics on the contents of an SRF file, both in terms of how many traces there are and the sort of data held within them. For efficiencies sake some control is given over which statistics to gather and display. This is controlled by the -l level parameter. The value is the summation of one or more of the following values, representing the data to display. 1 Count of good/bad reads. 2 Counts and compressed size for selected chunk types. 4 Trace count and trace name prefix for each trace_header. 8 Base count. OPTIONS
-l bitmap Controls which statistics to gather and display. Bitmap is a value from 0 to 15 (1+2+4+8) as described in the DESCRIPTION section above. EXAMPLES
To count the total number of good and bad reads along with a break down of trace names per SRF data-block-header we would use bitmap values 1 and 4 combined. srf_info -l 5 foo.srf To count the total number of reads for all srf files in a directory. srf_info -l 1 *.srf AUTHOR
Steven Leonard, Wellcome Trust Sanger Institute September 19 srf_info(1)
All times are GMT -4. The time now is 06:00 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy