Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 813
  • Last Modified:

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

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
Alaska Cowboy
Asked:
Alaska Cowboy
  • 3
  • 2
2 Solutions
 
simon3270Commented:
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
 
simon3270Commented:
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
 
simon3270Commented:
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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
woolmilkporcCommented:
awk  '{if(substr($0,86,9)!="MB6     0") print}' largefile > largefile.tmp
mv largefile.tmp largefile

wmp
0
 
Alaska CowboyAuthor Commented:
simon and woolmilkporc, thanks ! I will try both options.
0
 
Alaska CowboyAuthor Commented:
ok, both worked ! thanks.
0

Featured Post

[Webinar On Demand] Database Backup and Recovery

Does your company store data on premises, off site, in the cloud, or a combination of these? If you answered “yes”, you need a data backup recovery plan that fits each and every platform. Watch now as as Percona teaches us how to build agile data backup recovery plan.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now