LinuxQuestions.org
Latest LQ Deal: Linux Power User Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 02-16-2014, 12:29 PM   #1
sryzdn
Member
 
Registered: Feb 2013
Posts: 248

Rep: Reputation: 1
zero length file entry


Hi,

I am reading a text, it says:

Quote:
In the following command:
Quote:
ls -laU>file
the entry for file in the output gives zero length.
Could anyone explain what this "zero length" mean?
 
Old 02-16-2014, 01:33 PM   #2
jailbait
LQ Guru
 
Registered: Feb 2003
Location: Blue Ridge Mountain
Distribution: Debian Jessie, Linux Mint 17
Posts: 7,751

Rep: Reputation: 272Reputation: 272Reputation: 272
Zero length means that ls found nothing to list.

------------------
Steve Stites
 
Old 02-16-2014, 01:34 PM   #3
business_kid
LQ Guru
 
Registered: Jan 2006
Location: Ireland
Distribution: Slackware & Android
Posts: 7,570

Rep: Reputation: 697Reputation: 697Reputation: 697Reputation: 697Reputation: 697Reputation: 697
It's a name with a zero length file (not) attached. It's ok, linux is cool with that. If you don't want the name, you can usually delete it.

An example of where it is used is downloads. A zero length file is written
my_download.mp4
the file is actually downloaded to my_download.mp4.part and moved to the proper filename when it's complete.
 
Old 02-22-2014, 12:37 PM   #4
sryzdn
Member
 
Registered: Feb 2013
Posts: 248

Original Poster
Rep: Reputation: 1
Quote:
Originally Posted by sryzdn View Post
Hi,

I am reading a text, it says:

Quote:
In the following command:
ls -laU>file
the entry for file in the output gives zero length.


Could anyone explain what this "zero length" mean?
I have not yet got the answer. If there are files in the directory, ls -laU will list the names of the files and >file will print the list in "file". Why should there be any notion of "zero length" file here?
 
Old 02-22-2014, 12:59 PM   #5
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: CentOS
Posts: 2,961

Rep: Reputation: 1268Reputation: 1268Reputation: 1268Reputation: 1268Reputation: 1268Reputation: 1268Reputation: 1268Reputation: 1268Reputation: 1268
The file will have zero length initially. Until ls has generated enough buffered output to cause a write (the buffer will typically be 4KB), the file will still have zero length. I suspect that ls generates all the output and sorts it before writing anything, so the file will show as zero length.
 
Old 02-22-2014, 01:03 PM   #6
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,604

Rep: Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241
Quote:
Originally Posted by sryzdn View Post
I have not yet got the answer. If there are files in the directory, ls -laU will list the names of the files and >file will print the list in "file". Why should there be any notion of "zero length" file here?
First, the "file" is created by the shell before the "ls" command is executed. As a newly created file, it gets a zero length because no data is in the file...

Second, the data that will be put in the file is still in memory - it is all buffered in the application.

Now, if the directory has a LOT of files, (and this file is near the end of the list) you will see a non-zero length - but it still will not be complete until the last buffer is written.
 
1 members found this post helpful.
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Convert length-indicated variable length record file to LF-terminated Z038 Linux - General 10 11-30-2012 12:59 AM
[SOLVED] how to get the mid point (middle line ) of file, provided the length of file unknown vaibhavs17 Linux - Newbie 1 07-09-2012 03:53 PM
Delete lines from a file by their's length dayamoon Linux - Newbie 15 04-27-2010 08:58 PM
file creation with specified length linuxsavar Programming 2 03-01-2009 04:37 PM
BASH length of file baks Programming 14 03-13-2007 10:52 PM


All times are GMT -5. The time now is 12:35 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration