Don't display file name


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Don't display file name
# 1  
Old 04-17-2012
Bug Don't display file name

Hi

I have a directory where i have 10 -12 files, i want to store word count in seperate file without any file name.

i have written the logic which needs to be corrected
Code:
 filename.txt
for i in /backup/temp/rajesh/12Apr2012_South *.LOG
do
#echo "File size of $i is"
wc -l $i
done>lines.txt

Thanks

Rajesh

Last edited by methyl; 04-17-2012 at 10:57 AM.. Reason: please use code tags
# 2  
Old 04-17-2012
By redirecting the file to wc, rather than having wc open the file, wc will not print a filename.

Code:
for file in /backup/temp/*.LOG; do
    wc -l < "$file"
done > "lines.txt"

# 3  
Old 04-17-2012
Quote:
wc -l $i
Try
Code:
wc -l < $i

# 4  
Old 04-17-2012
Hi,

try this:

Code:
wc -l  /anywhere/file*.log |cut -d " " -f 1 > result.txt

Moderator's Comments:
Mod Comment Use code tags instead of quote tags, thank you

Last edited by Scrutinizer; 04-17-2012 at 01:00 PM..
# 5  
Old 04-17-2012
GNU sed if there are not too many files:
Code:
sed -sn '$=' file*

--
But the OP said he wanted to count words (wc -w) and we are all counting lines..

--
@pokerino: cut will not do here, because it uses single characters as separators and also the last number will be the total...
# 6  
Old 04-17-2012
correct:
Code:
wc -w *|awk -F " " '{print $1 }' > result.txt


Last edited by Scrutinizer; 04-17-2012 at 04:25 PM..
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Find command don't output anything, but file is there

Please if You can help me debug why nothing is found by this command? # echo "Zeus Robot" >> /home/vps/190/test # cat /home/vps/190/test Zeus Robot # find /home/vps -type f -mtime 2 -size -1000k -exec grep -l "Zeus Robot" {} \; >> out # cat out # cat /home/vps/190/test Zeus Robot Why... (6 Replies)
Discussion started by: postcd
6 Replies

2. UNIX for Dummies Questions & Answers

Change unix permission when I don't own the file

Hi, A file is transferred from a Windows server(say username : user1) to Unix server via ftp. In unix, the permission of the file for a user, say user2 will be "-rw-r-----". Since the user1 is the owner of the file, user2 is not able to change the file permission using chmod. Is there... (5 Replies)
Discussion started by: merin
5 Replies

3. UNIX for Dummies Questions & Answers

Why I don't see the time in some file/directory?

Hi all, When doing an ls -l, why is it that I have the date and time on some of the files and directory, while others don't? :wall: Is there a way to show the date and time using a different command? OS is Linux and Solaris. Any response much appreciated. Thanks in advance. (1 Reply)
Discussion started by: newbie_01
1 Replies

4. UNIX for Advanced & Expert Users

Don't find file from foxbase 2.1.2d

Hi there, finally i'm installed Sco Foxbase 2.1.2d over my Sco Open Server 5.0.7v server. Well at this point almost is working fine, but, when i Run mi application i receive the next error: "sh: the_name_of_file": does not exist". I checked it over the Hard Disk and the file exist, the... (1 Reply)
Discussion started by: danilosevilla
1 Replies

5. Shell Programming and Scripting

How to copy specific files when you don't know the file name?

I hope this isn't as silly as it sounds from the title of the thread. I have software that outputs files where the name starts with a real number followed by underscore as a prefix to an input file name. These will list in the directory with the file with the smallest real number prefix as the... (5 Replies)
Discussion started by: LMHmedchem
5 Replies

6. Shell Programming and Scripting

capture the last file when you don't know the all name

I have to ftp a file from a directory in Windows, I need to be able to ftp the last file that was put in the directory, the only thing I know about that file is that the 4 first digits are always the same (3520) then it is a _5(more digits), random digits, so it will be something like this... (1 Reply)
Discussion started by: rechever
1 Replies

7. UNIX for Dummies Questions & Answers

compress/decompress don't take you back to the same file

Hi there, I have a file system.tgz. I want to make changes inside this archive but before that, I want to be sure I recompress it in the exact same format. So I did the following: me:~# # Duplicate the archive --------------------------------- me:~# cp system.tgz system.01.tgz me:~# ls -l... (4 Replies)
Discussion started by: chebarbudo
4 Replies

8. Shell Programming and Scripting

Rename a file if I don't know its exact original name?

Hi everyone, I will be downloading a file every day with the name in this format SCA20060303_17514_IN.TXT And I need to rename it to SCA20060303_IN.TXT Where "20060303" is the current date, and the "_17514" part will always be a 5-digit number that I will NOT know beforehand. I... (9 Replies)
Discussion started by: propel
9 Replies

9. UNIX for Dummies Questions & Answers

Deleting a file I don't own

I have a directory with permissions set 777, and some gumby has dumped a bunch of files and directories in there. I don't own the culprit files or directories, but do own the containing directory - Is there some way I can delete this other user's files? The other interesting thing is that... (5 Replies)
Discussion started by: kumachan
5 Replies
Login or Register to Ask a Question