Solved

How can I remove a record from a large Unix file ?

Posted on 2011-03-25
6
803 Views
Last Modified: 2012-05-11
I have a Unix file that has a bad record in it that needs removed.

The file is too large for vi, it says "No space left on device".

So how can I remove the bad record ? it has "MB6     0" in position 86 for 9.

Through other testing, I also know what record # it is.
0
Comment
Question by:Alaska Cowboy
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 19

Accepted Solution

by:
simon3270 earned 75 total points
ID: 35215827
If you have enough space to store the big file twice:

    sed NNd bigfile > bigfile.copy

where NN is the record number (e.g. "sed 2d bigfile > bigfile2" to remove line 2).
0
 
LVL 19

Expert Comment

by:simon3270
ID: 35215845
This assumes that the "record" is a text line.  If this is a file sith some other format (fixed-length fields, binary values and so on) then "sed" won't work.
0
 
LVL 19

Expert Comment

by:simon3270
ID: 35215847
This assumes that the "record" is a text line.  If this is a file sith some other format (fixed-length fields, binary values and so on) then "sed" won't work.
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 68

Assisted Solution

by:woolmilkporc
woolmilkporc earned 50 total points
ID: 35215884
awk  '{if(substr($0,86,9)!="MB6     0") print}' largefile > largefile.tmp
mv largefile.tmp largefile

wmp
0
 
LVL 1

Author Comment

by:Alaska Cowboy
ID: 35216001
simon and woolmilkporc, thanks ! I will try both options.
0
 
LVL 1

Author Comment

by:Alaska Cowboy
ID: 35216126
ok, both worked ! thanks.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

My previous tech tip, Installing the Solaris OS From the Flash Archive On a Tape (http://www.experts-exchange.com/articles/OS/Unix/Solaris/Installing-the-Solaris-OS-From-the-Flash-Archive-on-a-Tape.html), discussed installing the Solaris Operating S…
Active Directory replication delay is the cause to many problems.  Here is a super easy script to force Active Directory replication to all sites with by using an elevated PowerShell command prompt, and a tool to verify your changes.
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question