Edit a Huge one line file


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Edit a Huge one line file
# 8  
Old 06-13-2012
Do you have the code for the program which wrote this file? It may be easier to write a program in the same programming language to read the file back.
# 9  
Old 06-13-2012
Quote:
Originally Posted by bakunin
vi typically uses /var/tmp per default, but can be configured to use other places too (at least to my knowledge all versions of vi offer such an option via the .exrc file). If this filesystem has not enough free space to hold the copy an attempt to edit the file will fail even if there would be enough space in memory to hold it.

Thanks for the tip.Could you please tell the command/alias to do the same?
I faced this problem couple of times but wasn't aware of any option like this..
# 10  
Old 06-13-2012
Code:
perl -pi -e 's/old_string/new_string/g' file_pattern

The above option worked.

Thank you all

Last edited by Scrutinizer; 06-14-2012 at 04:43 AM.. Reason: code tags
# 11  
Old 06-13-2012
Quote:
Originally Posted by clx
Thanks for the tip.Could you please tell the command/alias to do the same?
I faced this problem couple of times but wasn't aware of any option like this..
The file ".exrc" is usually located in your home directory and is a file automatically read whenever you start an instance of "vi". It holds all sorts of settings which you could set interactively too. Inside vi enter command mode (press <ESC> several times), press ":" to get to the command line and enter "set all" to see a list of available options. Here is what i use as an example, but that is personal taste (mine is in editors the same as in women: you-asked-for-it-you-get-it and no-bells-no-whistles-just-pure-efficieny):

Code:
# cat .exrc
" bakunins .exrc file, strip comments before use
set ai                     # automatic indenting
set sw=5                   # indenting width is 5 characters
set nonovice               # no "are you sure" nonsense
set terse                  # no nothing, i know what i do

set noshowmode             # this and the following is for vim to
set nomodeline             # switch off all the fancy stuff. I want an editor,
syntax off                 # not some Pacman-game with a text option
set nohlsearch
set noruler
set noshowmatch
set matchpairs=
set uc=0

I hope this helps.

bakunin
# 12  
Old 06-14-2012
Quote:
Originally Posted by bakunin
The file ".exrc" is usually located in your home directory and is a file automatically read whenever you start an instance of "vi". It holds all sorts of settings which you could set interactively too. Inside vi enter command mode (press <ESC> several times), press ":" to get to the command line and enter "set all" to see a list of available options.

Thanks for the information. I might not be clear in words about my query.
I am aware of .exrc file. Was just curious about the "set" option which need to be altered to change the directory from /var/tmp to something else.

Having look at set-all list, I think that should be one of the below.

Code:
  backupdir=.,~/tmp,~/
  backupskip=/tmp/*,/tmp/*,/tmp/*
  directory=.,~/tmp,/var/tmp,/tmp

# 13  
Old 06-14-2012
I think it's $TMPDIR . See man ex (which covers the core of vi).


Beware that unix vi has all sorts of limits that make it unsuitable for large files. This includes the number of records and the length of a record.
This User Gave Thanks to methyl For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Reading ALL BUT the first and last line of a huge file

Hi. Pardon me if I'm posting a duplicate thread but.. I have a text file with over 150 Million records, file size is in the range if MB(close to GB). The requirement is to read ALL the lines excepting the FIRST LINE which is the file header and the LAST LINE which is it's trailer record. ... (8 Replies)
Discussion started by: kumarjt
8 Replies

2. UNIX for Dummies Questions & Answers

Need to replace new line characters in a huge file

Hi , I would like to replace new line characters(\n) in a huge file of about 2 million records . I tried this one (:%s/\n//g) but it's hanging there and no result. Does this command do not work if the file is big. Please let me know if you have any other options Regards Raj (1 Reply)
Discussion started by: rajeevm
1 Replies

3. Shell Programming and Scripting

Edit first line of a text file

Hi friends, Issue1: I have a text file with the first line like this #chrom start end Readcount_A Normalized_Readcount_A ReadcountB Normalized_Readcount_B Fc_A_vs_B pvalue_A_vs_B FDR_A_vs_B Fc_B_vs_A pvalue_B_vs_A FDR_B_vs_A <a href="http://unix.com/">Link</a> How can I change it to the... (11 Replies)
Discussion started by: jacobs.smith
11 Replies

4. Shell Programming and Scripting

Optimised way for search & replace a value on one line in a very huge file (File Size is 24 GB).

Hi Experts, I had to edit (a particular value) in header line of a very huge file so for that i wanted to search & replace a particular value on a file which was of 24 GB in Size. I managed to do it but it took long time to complete. Can anyone please tell me how can we do it in a optimised... (7 Replies)
Discussion started by: manishkomar007
7 Replies

5. Shell Programming and Scripting

How to edit file to have one line entry?

Hello All, My file content is: DROP TABLE "FACT_WORLD"; CREATE TABLE "FACT_WORLD" ( "AR_ID" INTEGER NOT NULL, "ORG_ID" INTEGER NOT NULL ) DATA CAPTURE NONE COMPRESS YES; I want to change this file to have entries in one... (6 Replies)
Discussion started by: akash2508
6 Replies

6. Shell Programming and Scripting

Implement in one line sed or awk having no delimiter and file size is huge

I have file which contains around 5000 lines. The lines are fixed legth but having no delimiter.Each line line contains nearly 3000 characters. I want to delete the lines a> if it starts with 1 and if 576th postion is a digit i,e 0-9 or b> if it starts with 0 or 9(i,e header and footer) ... (4 Replies)
Discussion started by: millan
4 Replies

7. Shell Programming and Scripting

Edit a line in a file with perl

Hi, How can I edit a line in a file? For example, a.txt contains: start: 1 2 3 4 stop: a b c d and I want to change "3" to "9" and to add "5" after "4" the result should be (a.txt): start: 1 9 3 4 5 stop: a b c d Thanks, zed (5 Replies)
Discussion started by: zed
5 Replies

8. UNIX for Dummies Questions & Answers

How to remove FIRST Line of huge text file on Solaris

i need help..!!!! i have one big text file estimate data file size 50 - 100GB with 70 Mega Rows. on OS SUN Solaris version 8 How i can remove first line of the text file. Please suggest me for solutions. Thank you very much in advance:) (5 Replies)
Discussion started by: madoatz
5 Replies

9. UNIX for Dummies Questions & Answers

edit each line in the file

I am trying to edit each line in a file. The file has several columns delimitted by '|'. I need to take out the last two columns. Each line starts with a unique word through which I am storing the lines in a variable and cutting the last two colums. But, when I am echoing the line, it is... (2 Replies)
Discussion started by: chiru_h
2 Replies

10. UNIX for Advanced & Expert Users

Insert a line as the first line into a very huge file

Hello, I need to insert a line (like a header) as the first line of a very huge file (about 3 ml rows). I am able to do it with sed, but redirecting the output and creating a new file takes quite some time. I was wondering if there was a more efficient way of doing it? Any help would be... (3 Replies)
Discussion started by: shriek
3 Replies
Login or Register to Ask a Question