Deleting Characters at specific position in a line if the line is certain length


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Deleting Characters at specific position in a line if the line is certain length
# 8  
Old 12-16-2008
Ok - tried that. Now it tells me cannot have more than 199 fields (referencing the first line that needs correction)
# 9  
Old 12-16-2008
Quote:
Originally Posted by Cailet
Ok - tried that. Now it tells me cannot have more than 199 fields (referencing the first line that needs correction)
ok, it's the limitation of your version of awk.
lets try to fool it by setting the field separator to something would not appear in the data file - no guarantee that it would not like something else:
Code:
awk -F'^' -f cailet.awk $oldFile > $newFile

# 10  
Old 12-16-2008
deleted

Last edited by Cailet; 12-16-2008 at 04:51 PM.. Reason: page didn't refresh so thought my last post didn't go....
# 11  
Old 12-17-2008
Alrighty-
so no matter what I tried it kept giving me the "can't have more than 199 fields" error. (Looks like the file has 202 - arg)

I think I figured out how to get rid of the extra characters (still need to verify that the invalid lines will have exactly the same data as the test file) with a sed command

now I just need to figure out how to either separate the invalid lines into a different file (to use sed)
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Remove line break at specific position

Hi, I need to remove line breaks from a file, but only the ones at specific position. Input file: this is ok this line is divided at posit ion 30. The same as this one, also position 30 the rest of lines are ok with different lengths The longest ones are always s plitted at same... (15 Replies)
Discussion started by: qranumo
15 Replies

2. Shell Programming and Scripting

Need help on find and replacement on specific line and position

I have a file with 100 lines. On 50 th line , from position 5 to rest of the data , I need to change the occurrence of A to B and Occurrence of M to N. Input file : Line1 Line2 Line3 -- -- 12345ABCDEFM --- -- Line 100 Output Line1 Line2 (40 Replies)
Discussion started by: Rajesh_us
40 Replies

3. UNIX for Dummies Questions & Answers

Help with awk, where line length and field position are variable

I have several questions about using awk. I'm hoping someone could lend me a hand. (I'm also hoping that my questions make sense.) I have a file that contains pipe separated data. Each line has similar data but the number of fields and the field position on each line is variable. ... (3 Replies)
Discussion started by: Cheese64
3 Replies

4. Shell Programming and Scripting

Extract substring specif position and length from file line

Hi gurus, I am trying to figure out how to extract substring from file line (all lines in file), as specified position and specified legth. Example input (file lines) dhaskjdsa dsadhkjsa dhsakjdsad hsadkjh dsahjdksahdsad sahkjd sahdkjsahd sajkdh adhjsak I want to extract substring on... (5 Replies)
Discussion started by: ProsteJa
5 Replies

5. Shell Programming and Scripting

Printing characters at specific position in line

Hi, I am trying to get an output like : +----------------------------------+ ----------- + + some variable substitution + some text + Is there a way I can specify in printf (in ksh) the particular position I want to print a character, and also repeat a character from... (1 Reply)
Discussion started by: neil.k
1 Replies

6. Shell Programming and Scripting

Deleting new line characters

Hi, I have a weird requirement. I am having a file with 12fields in it and the end of the line for each record is "\n" (Just \n and no carriage returns) and the field delimiter is "|". Problem is I can have new line characters in any field in the data and these new line characters can even come... (11 Replies)
Discussion started by: ngkumar
11 Replies

7. Shell Programming and Scripting

Removing characters from end of line (length unknown)

Hi I have a file which contains wrong XML, There are some garbage characters at the end of line that I want to get rid of. Example: <request type="product" ><attributes><pair><name>q</name><value><!]></value></pair><pair><name>start</name><value>1</value></pair></attributes></request>�J ... (7 Replies)
Discussion started by: dirtyd0ggy
7 Replies

8. Shell Programming and Scripting

Search in specific position and print the whole line

I have two files abc.dat and sant.dat (Big file 60k rows) for every line's 1,4 of abc.dat need to seach if this is present on 28,4 of sant.dat every line. if its present the output needs to go to bde.dat Example: contents abc.dat aaaa bbbb cccc dddd contents sant.dat this is... (4 Replies)
Discussion started by: ssantoshss
4 Replies

9. UNIX for Dummies Questions & Answers

Need help with deleting certain characters on a line

I have a file that looks like this: It is a huge file and basically I want to delete everything at the > line except for the number after “C”. >c1154... (2 Replies)
Discussion started by: kylle345
2 Replies

10. Shell Programming and Scripting

Deleting First Two Characters On Each Line

How would one go about deleting the first two characters on each line of a file on Unix? I thought about using awk, but cannot seem to find if it can explicitly do this. In this case there might or might not be a field separator. Meaning that the data might look like this. 01999999999... (5 Replies)
Discussion started by: scotbuff
5 Replies
Login or Register to Ask a Question