Sponsored Content
Special Forums Hardware Filesystems, Disks and Memory finding empty files that are padded with zeros Post 302144579 by Smiling Dragon on Thursday 8th of November 2007 08:38:07 PM
Old 11-08-2007
Quote:
Originally Posted by polive96
how can search for files that are non-zero length but are empty?
That's not really something that can happen. A non-zero file is, by definition, not empty.

To find a file that contains nothing but '0' characters. I'd try something like this
Code:
for file in <filenames>; do if egrep -v -e '^0*$' $file > /dev/null; then echo "do nothing" > /dev/null else echo "{}"; fi ; done

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Problem with echo for var, padded with spaces

While concatenating 2 values, one which expanded to fixed width & other not, I am not getting value expanded as fixed width. Following is script for the same : #!/bin/sh var1="abc" var2="def" var1Fxd=`echo $var1 | awk '{printf("%-6s",$0)}'` echo $var1Fxd""$var2 But, if I try - echo... (2 Replies)
Discussion started by: videsh77
2 Replies

2. Shell Programming and Scripting

finding duplicate files by size and finding pattern matching and its count

Hi, I have a challenging task,in which i have to find the duplicate files by its name and size,then i need to take anyone of the file.Then i need to open the file and find for more than one pattern and count of that pattern. Note:These are the samples of two files,but i can have more... (2 Replies)
Discussion started by: jerome Sukumar
2 Replies

3. Shell Programming and Scripting

Move and rename files in seq. with padded digits

Greetings, I am new to scripting, but find if I can see the code working for a given problem, then I can eventually figure it out. (9 Replies)
Discussion started by: rocinante
9 Replies

4. Shell Programming and Scripting

Empty Files

Hi, How can I check if a file is empty? I have read that I could done in this way: if then echo "non-zero length file" fi But nothing happens (3 Replies)
Discussion started by: DNAx86
3 Replies

5. UNIX for Dummies Questions & Answers

How to left trim padded zeroes

I have a filename 'INITIATE_FINAL_ALL_000080889.dat', and I want to capture just the number '80889' from it. Here is what I have so far: %> echo INITIATE_FINAL_ALL_000080889.dat | sed "s/*//g" 000080889 Now, I just need to trim off the padded zeroes. Thanks, - CB (3 Replies)
Discussion started by: ChicagoBlues
3 Replies

6. Shell Programming and Scripting

Using Seq As A Variable With Padded Digits

Hi all. Im trying to use a sequence in a while loop like this below. I need it for navigating a year, month, day folder structure where a user can input the start date and have it go to the desired end date. The script will grab a certain file on each day then move onto the next. Ive got all that... (3 Replies)
Discussion started by: Grizzly
3 Replies

7. Shell Programming and Scripting

To empty the files

Hi, Using the shell script, how can I empty the files that are under a dir. -Siva (2 Replies)
Discussion started by: gsiva
2 Replies

8. Shell Programming and Scripting

Help with script to add two zeros to certain lines in a set of files?

Hello... I should be better with scripting but I am not so turning here for some help. I did search quite a bit using google and didn't find anything meeting my needs for this. What am after here is a script (in a redhat linux env) that will read in a small series of files (netbackup vault... (6 Replies)
Discussion started by: abg1969
6 Replies

9. Shell Programming and Scripting

Comma padded.. Output

Hello, here is the outout of the command below.. Can someone please tell me how to get the output as below output needed: 18914,30716,17051,4139,14155... ( no comma for the last value) ps -e -o pcpu,pid,user,tty,args | sort -n -k 1 -r | head | awk '{print $2}' 18914 30716 17051 4139... (10 Replies)
Discussion started by: kamathg
10 Replies

10. Shell Programming and Scripting

Printf padded string

Is possible to print padded string in printf? Example echo 1 | awk '{printf("%03d\n", $1)}' 001I want S1 S11 S2 S21to be padded as: S01 S11 S02 S21Thanks! (26 Replies)
Discussion started by: yifangt
26 Replies
mkfile(1M)																mkfile(1M)

NAME
mkfile - create a file SYNOPSIS
mkfile [-nv] size [g | k | b | m] filename... mkfile creates one or more files that are suitable for use as NFS-mounted swap areas, or as local swap areas. When a root user executes mkfile(), the sticky bit is set and the file is padded with zeros by default. When non-root users execute mkfile(), they must manually set the sticky bit using chmod(1). The default size is in bytes, but it can be flagged as gigabytes, kilobytes, blocks, or megabytes, with the g, k, b, or m suffixes, respectively. -n Create an empty filename. The size is noted, but disk blocks are not allocated until data is written to them. Files created with this option cannot be swapped over local UFS mounts. -v Verbose. Report the names and sizes of created files. USAGE
See largefile(5) for the description of the behavior of mkfile when encountering files greater than or equal to 2 Gbyte ( 2**31 bytes). See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Availability |SUNWcsu | +-----------------------------+-----------------------------+ chmod(1), swap(1M), attributes(5), largefile(5) 2 Feb 2001 mkfile(1M)
All times are GMT -4. The time now is 05:20 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy