[wellylug] BASH scripting help required

Tim Nicholas tim at nicholas.net.nz
Fri May 7 12:31:11 NZST 2004


On 07/05/04 12:29, E.Chalaron wrote:
> BTW how do you remove blank files with sed ?
> Thanks
> Edouard
> 
> 
>>for file in $( ls )
>>do
>>   firstChar=$(echo $file | sed -r 's/^(.)/\1/')
>>   echo $firstChar;
>>done
> 
> 
> 

blank files or blank lines?

empty lines are matched by /^$/ and empty files can be matched with 
test. Especially look at the -s test (matches files that exist and 
aren't zero length).

Tim

-- 
Tim Nicholas                          ||                      Cilix
Email: tim at nicholas.net.nz            ||    Wellington, New Zealand
http://tim.nicholas.net.nz/           ||   Cell/SMS: +64 21 337 204




More information about the wellylug mailing list