Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

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

Posted on 2011-03-25
6
Medium Priority
?
810 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 20

Accepted Solution

by:
simon3270 earned 300 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 20

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 20

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 200 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

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.

Question has a verified solution.

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

I promised to write further about my project, and here I am.  First, I needed to setup the Primary Server.  You can read how in this article: Setup FreeBSD Server with full HDD encryption (http://www.experts-exchange.com/OS/Unix/BSD/FreeBSD/A_3660-S…
Utilizing an array to gracefully append to a list of EmailAddresses
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…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
Suggested Courses

618 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