VI command "line too long"

 
Thread Tools Search this Thread
Top Forums UNIX for Beginners Questions & Answers VI command "line too long"
# 1  
Old 07-14-2016
Question VI command "line too long"

Hello, I had posted this initially in the UNIX for dummies forum which is now locked to new posts. I have a machine running IRIX and I need to edit a text file on the terminal but I get a "line too long" error when using the vi command. The text file in question is tens of thousands in lines so I'm not sure if that is related to it. User bakunin suggested the sed command but I get similar results. Can someone show me step by step on a possible workaround with this since I'm a bit rusty on this stuff? Thanks in advance!

James
# 2  
Old 07-15-2016
By definition, text files meet all of the following requirements:
  1. the file does not contain any NUL characters,
  2. every line in the file is terminated by a <newline> character, and
  3. no line in the file (including the terminating <newline> character) contains more than LINE_MAX bytes.
On many systems, LINE_MAX is 2048. The value on your system can be determined using the command:
Code:
getconf LINE_MAX

The message you are getting probably indicates that the file you are trying to edit is not a text file because it violates requirement #3 in the list above.

If you want to split long lines in a file into shorter, adjacent lines that meet the requirements of a text file, try using the fold utility. If you want to split long lines into segmented files where one file contains the 1st X characters from each line from an input file and another file contains the X+1st through the 2Xth character from each line from an input file, etc.; try using the cut utility.

Without knowing more about the format and contents of the file you are trying to edit and the changes you want to make to that file, it is hard to suggest anything more specific.
These 3 Users Gave Thanks to Don Cragun For This Post:
# 3  
Old 07-15-2016
Hi Don thanks for your reply. The files I'm trying to view are .dat files. The maximum number of lines is 2048 like you suggested. I don't believe there are any <newline> tags located within the contents of the files.
# 4  
Old 07-15-2016
'newline' is a single ascii character, ASCII 10, usually written by us humans and sometimes UNIX utilities as \n

It is not the number of lines in the file, LINE_MAX refers to line length. The longest allowed length of any one line in the file. Or. The maximum number of bytes allowed in a line. Further, lines are defined as having the newline character (\n) at the end of the line.

Files that have a logical structure but no \n characters, or files with lines that do have carriage control (\n exists) but with lines > 2048 bytes will get this error.

Last edited by jim mcnamara; 07-15-2016 at 12:15 PM..
# 5  
Old 07-18-2016
Quote:
Originally Posted by jim mcnamara
'newline' is a single ascii character, ASCII 10, usually written by us humans and sometimes UNIX utilities as \n

It is not the number of lines in the file, LINE_MAX refers to line length. The longest allowed length of any one line in the file. Or. The maximum number of bytes allowed in a line. Further, lines are defined as having the newline character (\n) at the end of the line.

Files that have a logical structure but no \n characters, or files with lines that do have carriage control (\n exists) but with lines > 2048 bytes will get this error.
So are you saying there is no way around this (i.e. I can't increase the limit)? The file I'm trying to edit is a .dat data file for a program so I don't want to make new lines and potentially break something.
# 6  
Old 07-18-2016
Quote:
Originally Posted by James C
Hello, I had posted this initially in the UNIX for dummies forum which is now locked to new posts. I have a machine running IRIX and I need to edit a text file on the terminal but I get a "line too long" error when using the vi command. The text file in question is tens of thousands in lines so I'm not sure if that is related to it. User bakunin suggested the sed command but I get similar results. Can someone show me step by step on a possible workaround with this since I'm a bit rusty on this stuff? Thanks in advance!

James
You say above that you have a text file; but we have showed you the definition of a text file and your .dat file(s) do NOT meet the definition of a text file. You say above that your text file has thousands of lines, but in post #3 in this thread you say that there are no <newline> characters. So by definition, your .dat file doesn't contain any lines.

Why do you say that you have thousands of lines in a file if there are no <newline> characters and you know that every line in a file is terminated by a <newline> character?

We can't help you if you don't explain the format of the data in your .dat file(s) and explain what change(s) you hope to make to your .dat file(s)
# 7  
Old 07-19-2016
Haven't done it with Unix tools but did it with basic under MSDOS, reading character by character from the .dat file, writing to a new .txt file character by character and converting a delimiter to a line break at the correct place.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Failure: if grep "$Var" "$line" inside while read line loop

Hi everybody, I am new at Unix/Bourne shell scripting and with my youngest experiences, I will not become very old with it :o My code: #!/bin/sh set -e set -u export IFS= optl="Optl" LOCSTORCLI="/opt/lsi/storcli/storcli" ($LOCSTORCLI /c0 /vall show | grep RAID | cut -d " "... (5 Replies)
Discussion started by: Subsonic66
5 Replies

2. Shell Programming and Scripting

Delete all log files older than 10 day and whose first string of the first line is "MSH" or "<?xml"

Dear Ladies & Gents, I have a requirement to delete all the log files in /var/log/test directory that are older than 10 days and their first line begin with "MSH" or "<?xml" or "FHS". I've put together the following BASH script, but it's erroring out: for filename in $(find /var/log/test... (2 Replies)
Discussion started by: Hiroshi
2 Replies

3. Shell Programming and Scripting

Move a line containg "char" above line containing "xchar"

Okay, so I have a rather large text file and will have to process many more and this will save me hours of work. I'm not very good at scripting, so bear with me please. Working on Linux RHEL I've been able to filter and edit and clean up using sed, but I have a problem with moving lines. ... (9 Replies)
Discussion started by: rex007can
9 Replies

4. Shell Programming and Scripting

How to avoid "Too many arguments" error, when passing a long String literal as input to a command?

Hi, I am using awk here. Inside an awk script, I have a variable which contains a very long XML data in string format (500kb). I want to pass this data (as argument) to curl command using system function. But getting Too many arguments error due to length of string data(payloadBlock). I... (4 Replies)
Discussion started by: cool.aquarian
4 Replies

5. UNIX for Dummies Questions & Answers

Using "mailx" command to read "to" and "cc" email addreses from input file

How to use "mailx" command to do e-mail reading the input file containing email address, where column 1 has name and column 2 containing “To” e-mail address and column 3 contains “cc” e-mail address to include with same email. Sample input file, email.txt Below is an sample code where... (2 Replies)
Discussion started by: asjaiswal
2 Replies

6. Shell Programming and Scripting

Find lines with "A" then change "E" to "X" same line

I have a bunch of random character lines like ABCEDFG. I want to find all lines with "A" and then change any "E" to "X" in the same line. ALL lines with "A" will have an "X" somewhere in it. I have tried sed awk and vi editor. I get close, not quite there. I know someone has already solved this... (10 Replies)
Discussion started by: nightwatchrenba
10 Replies

7. Shell Programming and Scripting

awk command to replace ";" with "|" and ""|" at diferent places in line of file

Hi, I have line in input file as below: 3G_CENTRAL;INDONESIA_(M)_TELKOMSEL;SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL My expected output for line in the file must be : "1-Radon1-cMOC_deg"|"LDIndex"|"3G_CENTRAL|INDONESIA_(M)_TELKOMSEL"|LAST|"SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL" Can someone... (7 Replies)
Discussion started by: shis100
7 Replies

8. Shell Programming and Scripting

Command to view full data "export MAESTRO_OUTPUT_STYLE=LONG"

Hi, Always when I login to Unix, I need to give the following command to view the data properly; export MAESTRO_OUTPUT_STYLE=LONG The reason is that by default the settings export MAESTRO_OUTPUT_STYLE=SHORT Please let me know how I could make LONG as the default and avoid giving the... (1 Reply)
Discussion started by: jmathew99
1 Replies

9. Shell Programming and Scripting

each line as 20digit long append zero "0" in front

i have an ip file like 121 1213412 34345353 long file want to made each line as 20digit long append zero "0" in front as 121 become 00000000000000000121 (1 Reply)
Discussion started by: RahulJoshi
1 Replies

10. UNIX for Dummies Questions & Answers

Explain the line "mn_code=`env|grep "..mn"|awk -F"=" '{print $2}'`"

Hi Friends, Can any of you explain me about the below line of code? mn_code=`env|grep "..mn"|awk -F"=" '{print $2}'` Im not able to understand, what exactly it is doing :confused: Any help would be useful for me. Lokesha (4 Replies)
Discussion started by: Lokesha
4 Replies
Login or Register to Ask a Question