05-03-2006
follow these steps
1> check for spaces using sed remove all the spaces
2> use an if condition to check the size of the file like
if [[ ! -s txt ]] then
echo " empty "
else
echo "non empty"
fi
3) now delete in if statement
rm -f txt.
-Manish Jha
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
as of our requiremnt some x no of files will be created from a third party tool ,out of them one or two files will be empty i.e size is 0. so i want to remove those files which are empty.
naming of the files which are created will be like this
abc_.txt 0 size
abc_1.txt 4000 size
abc_2.txt... (1 Reply)
Discussion started by: srivsn
1 Replies
2. Shell Programming and Scripting
Hello Gurus,
I want to delete only empty files (files with 0 bytes) at once from the local directory. Rightnow I need to go through all the files one by one manually and check the empty files before deleting them. Is there any unix command that finds and deletes empty files in a directory?... (5 Replies)
Discussion started by: berlin_germany
5 Replies
3. UNIX for Dummies Questions & Answers
Hi All,
I am checking for a empty input file to do some further action , but I am getting exit status 0 in both the cases , for empty and non empty file both.
The value of $? is coming 0 in if part also and else part too.
#!/bin/ksh
if ]; then
echo "data"
# exit 0
echo "$?"
else... (4 Replies)
Discussion started by: mavesum
4 Replies
4. Shell Programming and Scripting
Hello Friends,
Im trying to delete empty files in subdirectories with a command. I can find them checking only one directory in each step and then show them with my command like below moreover i could not add removing part:
ls -l */* | awk '{if ($5==0) printf "%3s %2d %s... (5 Replies)
Discussion started by: EAGL€
5 Replies
5. Shell Programming and Scripting
Hello, I'm submitting this thread, because I was looking a way to delete empty directories using find and I found a thread from 2007 that helped me. I have worked from that threat, but I found that the command sent would analyze original directory and may delete it to. I have come up with expanded... (3 Replies)
Discussion started by: lramirev
3 Replies
6. Shell Programming and Scripting
I have the test data with 10 column separated by comma and each column has more than 1000000 rows. Can anyone help me to find empty field in all columns and delete that empty field alone and lift that column up by one row.
Data with empty field:
A74203XYZ,A21718XYZ,A72011XYZ,A41095XYZ,... (7 Replies)
Discussion started by: zooby
7 Replies
7. SCO
I know someone will probably laugh at this question, I probably knew the answer many years ago when I was doing this full time but here goes.....
I have a directory that has many files and sub-directories in it, RMDIR will not delete a directory that is not empty so what is the command to... (1 Reply)
Discussion started by: moondogi
1 Replies
8. UNIX for Dummies Questions & Answers
I have a text file that looks like this:
1 rs523634 8.22486
1
1 rs585160 8.22488
1 rs497228 8.2249
1
1 rs600933 8.225
1 rs480106 8.22531
1 rs600199 8.22533
1 rs529015 8.22534
1 rs598894 8.22534
I want to delete the rows with empty... (2 Replies)
Discussion started by: evelibertine
2 Replies
9. Shell Programming and Scripting
Hey, I need help with writing a shell script that deletes empty folders..anyone? :)
Thank you! (5 Replies)
Discussion started by: putukas
5 Replies
10. Shell Programming and Scripting
The below awk improved bu @MadeInGermany, works great as long as the input file has data in it in the below format:
input
chrX 25031028 25031925 chrX:25031028-25031925 ARX 631 18
chrX 25031028 25031925 chrX:25031028-25031925 ARX 632 14... (3 Replies)
Discussion started by: cmccabe
3 Replies
DEFINED(3) 1 DEFINED(3)
defined - Checks whether a given named constant exists
SYNOPSIS
bool defined (string $name)
DESCRIPTION
Checks whether the given constant exists and is defined.
Note
If you want to see if a variable exists, use isset(3) as defined(3) only applies to constants. If you want to see if a function
exists, use function_exists(3).
PARAMETERS
o $name
- The constant name.
RETURN VALUES
Returns TRUE if the named constant given by $name has been defined, FALSE otherwise.
EXAMPLES
Example #1
Checking Constants
<?php
/* Note the use of quotes, this is important. This example is checking
* if the string 'TEST' is the name of a constant named TEST */
if (defined('TEST')) {
echo TEST;
}
?>
SEE ALSO
define(3), constant(3), get_defined_constants(3), function_exists(3), The section on Constants.
PHP Documentation Group DEFINED(3)