Sponsored Content
Top Forums Shell Programming and Scripting Tried many options but unable to delete blank lines from text file Post 303000923 by uuuunnnn on Monday 24th of July 2017 01:46:24 AM
Old 07-24-2017
Tried many options but unable to delete blank lines from text file

Hi,

I tried the following options but was unable to delete blank lines from file

Input file = temp.hash.txt
temp.hash.txt content
Code:
90

0

89.56
0
0


57575.4544
56.89




0


0
0
0

----------------------------
Options tried
  1. sed '/^$/d' temp.hash.txt > temp.hash.out
  2. grep '[^[:blank:]]' < temp.hash.txt > temp.hash.out
  3. awk 'NF' temp.hash.txt
  4. sed -i '/^$/d' temp.hash.txt
  5. grep -v '^$' temp.hash.txt > output.txt

Nothing worked.

Any help is appreciated!

Thanks...


Moderator's Comments:
Mod Comment Please use CODE tags as required by forum rules!

Last edited by rbatte1; 07-24-2017 at 11:20 AM.. Reason: RudiC Added CODE tags; rbatte1 Converted to formatted numeric list
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

regex to delete multiple blank lines in a file?

can't figure out a way to delete multiple empty lines but keep single empty lines in a file, file is like this #cat file 1 2 3 4 5 6 - What I want is 1 2 (6 Replies)
Discussion started by: fedora
6 Replies

2. Shell Programming and Scripting

Delete blank lines at the end of file

I am attempting to delete blank lines in my file and I've used this command: sed '/^$/d' $file > $file.fixed all this seems to do is copy the file and not delete the blank lines located at the end of the file. Any assistance would be greatly appreciated. (3 Replies)
Discussion started by: TL56
3 Replies

3. UNIX for Dummies Questions & Answers

delete blank lines from a file

can anyone show me how to delete blank lines from a file. thanks in advance (2 Replies)
Discussion started by: sachin.gangadha
2 Replies

4. Shell Programming and Scripting

Delete a block of text delimited by blank lines when pattern is found

I have a file which contains blocks of text - each block is a multi-lines text delimited by blank lines eg. <blank line> several lines of text ... pattern found on this line several more lines of text ... <blank line> How do you delete the block of text (including the blank lines) when... (17 Replies)
Discussion started by: gleu
17 Replies

5. UNIX for Dummies Questions & Answers

Remove blank lines and comments from text file

Hi, I am using BASH. How can I remove any lines in a text file that are either blank or begin with a # (ie. comments)? Thanks in advance. Mike (3 Replies)
Discussion started by: msb65
3 Replies

6. Shell Programming and Scripting

Delete blank lines from a file

Hi, I want to use diff to compare two files in a Perl file. But one of the files has some blank lines at the end. So I want to delete the blank lines from the file firstly and then use diff to compare them. But I dont know how to delete the blank lines from the files. Meanwhile, the system is... (5 Replies)
Discussion started by: Damon_Qu
5 Replies

7. Shell Programming and Scripting

Delete blank lines, if blank lines are more than one using shell

Hi, Consider a file named "testfile" The contents of file are as below first line added for test second line added for test third line added for test fourth line added for test fifth line added for test (5 Replies)
Discussion started by: anil8103
5 Replies

8. Shell Programming and Scripting

Delete the last empty/blank line of the text file

Hi All, I have a file.txt which seems like having three lines. wc -l file.txt 3 file.txt In fact, once it is open in text editor, this file has four lines where the last line is empty. how can i delete this last empty line of the file.txt? I tried the codes below so far but they... (6 Replies)
Discussion started by: senayasma
6 Replies

9. Shell Programming and Scripting

Delete blank lines in a file

Hi All, I have a file and I need to delete the lines that are blank and is starting with some characters below. Something like below: Regular Ascii File: Line1: AGODA1 BUSAN||SK Lord Beach 4/6/2012 4/7/2012 68060 Line2: AGODA2 BUSAN||SK Beach Hotel 4/6/2012 4/7/2012 610200 Line3: ... (4 Replies)
Discussion started by: rkumar28
4 Replies

10. UNIX for Advanced & Expert Users

Delete blank spaces and blank lines in a file

Hi Gurus, Somebody can say me how to delete blank spaces and blank lines in a file unix, please. Thank you for advanced. (10 Replies)
Discussion started by: systemoper
10 Replies
HASH_FILE(3)								 1							      HASH_FILE(3)

hash_file - Generate a hash value using the contents of a given file

SYNOPSIS
string hash_file (string $algo, string $filename, [bool $raw_output = false]) DESCRIPTION
PARAMETERS
o $algo - Name of selected hashing algorithm (i.e. "md5", "sha256", "haval160,4", etc..) o $filename - URL describing location of file to be hashed; Supports fopen wrappers. o $raw_output - When set to TRUE, outputs raw binary data. FALSE outputs lowercase hexits. RETURN VALUES
Returns a string containing the calculated message digest as lowercase hexits unless $raw_output is set to true in which case the raw binary representation of the message digest is returned. EXAMPLES
Example #1 Using hash_file(3) <?php /* Create a file to calculate hash of */ file_put_contents('example.txt', 'The quick brown fox jumped over the lazy dog.'); echo hash_file('md5', 'example.txt'); ?> The above example will output: 5c6ffbdd40d9556b73a21e63c3e0e904 SEE ALSO
hash(3), hash_hmac_file(3), hash_update_file(3), md5_file(3), sha1_file(3). PHP Documentation Group HASH_FILE(3)
All times are GMT -4. The time now is 06:25 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy