Write the total number of rows in multiple files into another file


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Write the total number of rows in multiple files into another file
# 1  
Old 03-30-2012
Write the total number of rows in multiple files into another file

Hello Friends,

I know you all are busy and inteligent too...

I am stuck with one small issue if you can help me then it will be really great.

My problem is I am having some files i.e.

Input.txt1
Input.txt2
Input.txt3

Now my task is I need to check the total number of rows in the above 3 files and then write only the numeric value( total number of rows in that file) into another file.

so for this I have given the below command:

Code:
wc -l < Input.txt* > MyFile.txt

But its giving me the below error:

A file or directory in the path name does not exist.
ksh: ISI_SAP_Sourcing*: 0403-016 Cannot find or open the file.



Can anyone please help me.

Last edited by Scrutinizer; 03-30-2012 at 04:55 AM.. Reason: Please Use [code] tags [/code], thank you..
# 2  
Old 03-30-2012
When you redirect you can only specify one file. Try:
Code:
wc -l Input.txt* > MyFile.txt

# 3  
Old 03-30-2012
@ Scrutinizer,

I have tried this but the out I am getting in the MyFile.txt is :

Code:
       8 ISI_SAP_Sourcing_20120316_065816.txt
       1 ISI_SAP_Sourcing_20120329_010112.txt
       1 ISI_SAP_Sourcing_20120330_011023.txt
      10 total

But I don't want all these above contents.

See in my all those 3 input files I am having total 10 number of rows.

So in my output file that is MyFile.txt , I need the output as only 10.

I don't need any other information in my output file.

Hope you understood my point.

Moderator's Comments:
Mod Comment Please use code tags

Last edited by Scrutinizer; 03-30-2012 at 04:57 AM..
# 4  
Old 03-30-2012
Try concatenating (cat) first:
Code:
cat Input*.txt | wc -l > MyFile.txt

This User Gave Thanks to Scrutinizer For This Post:
# 5  
Old 03-30-2012
Thanks mate its working......
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Performance of calculating total number of matching records in multiple files

Hello Friends, I've been trying to calculate total number of a certain match in multiple data records files (DRs). Let say I have a daily created folders for each day since the beginning of july like the following drwxrwxrwx 2 mmsuper med 65536 Jul 1 23:59 20150701 drwxrwxrwx 2 mmsuper... (1 Reply)
Discussion started by: EAGL€
1 Replies

2. Shell Programming and Scripting

Total number of files in the folder should be listed

Hi All, When i give the ls -lrt to list out all files with total number of files , i get the output as ls -lrt total 72 -rw-r--r-- 1 hari staff 796 Jul 11 09:17 va.txt -rw-r--r-- 1 hari staff 169 Jul 13 00:20 a.log -rwxr-xr-x 1 hari staff 659 Aug... (9 Replies)
Discussion started by: Kalaihari
9 Replies

3. Shell Programming and Scripting

How to count number of files in directory and write to new file with number of files and their name?

Hi! I just want to count number of files in a directory, and write to new text file, with number of files and their name output should look like this,, assume that below one is a new file created by script Number of files in directory = 25 1. a.txt 2. abc.txt 3. asd.dat... (20 Replies)
Discussion started by: Akshay Hegde
20 Replies

4. HP-UX

Total number of files in a FS

Hello people, On HP-UX B.11.11 U 9000/800 How can I have in aprox. the total number of files in a specific FS? Is the number of used inodes a rough estimation of my total number of files? Server1 /Data:df -i . /Data (/dev/vg_Data/lvol1 ) : 18292960 total i-nodes 15800945 free... (3 Replies)
Discussion started by: drbiloukos
3 Replies

5. UNIX for Dummies Questions & Answers

How to separate a single column file into files of the same size (i.e. number of rows)?

I have a text file with 1,000,000 rows (It is a single column text file of numbers). I would like to separate the text file into 100 files of equal size (i.e. number of rows). The first file will contain the first 10,000 rows, the second row will contain the second 10,000 rows (rows 10,001-20,000)... (2 Replies)
Discussion started by: evelibertine
2 Replies

6. UNIX for Dummies Questions & Answers

Command for total number of files (and size) across subdirectories?

Hi all... I have a directory called dbrn. This directory contains an unknown number of subdirectories which in turn contain an unknown number of files. What I want to know is: How many files with extention .ABC can be found in /dbrn across all subdirecties, and what is the total size for... (9 Replies)
Discussion started by: Beun
9 Replies

7. Shell Programming and Scripting

write to multiple files depending on file type (solved)

I want a script that will add comments to a file before check-in files. comments depend on type of files. i have a script to list files in the directory that will be checked-in There are xml, js, html, vm files. vm will use comments like c/c++ ( // or /*..*/) can you help me add a comment line... (0 Replies)
Discussion started by: pradeepmacha
0 Replies

8. UNIX Desktop Questions & Answers

Need to ftp some files, and check the number of rows in the transferd file

1)I need to write a script which ftps 3 files to a unix box, 2)once the files are ftped i need to check the number of rows in each file and compare it with the data (no of rows) coming in a manifest file, if the number of rows in each file matches the data coming in manifest file, then i need to... (3 Replies)
Discussion started by: imran_affu
3 Replies

9. UNIX for Dummies Questions & Answers

total number of files which have "aaa" in files whose names are File*_bbb*

I am getting the list of all the files which have "aaa" from files whose name is File*_bbb*. grep -l "aaa" File*_bbb* But I want to count the number of files. That is I want the total number of files which have "aaa" in files File*_bbb* If I run the following for getting number of... (1 Reply)
Discussion started by: sudheshnaiyer
1 Replies

10. UNIX for Dummies Questions & Answers

grep running total/ final total across multiple files

Ok, another fun hiccup in my UNIX learning curve. I am trying to count the number of occurrences of an IP address across multiple files named example.hits. I can extract the number of occurrences from the files individually but when you use grep -c with multiple files you get the output similar to... (5 Replies)
Discussion started by: MrAd
5 Replies
Login or Register to Ask a Question