Linux script to remove a character in a file based on position.


 
Thread Tools Search this Thread
Operating Systems Linux Linux script to remove a character in a file based on position.
# 1  
Old 02-01-2012
Linux script to remove a character in a file based on position.

Greetings,

We have a requirement where we need to loop in a fixed width file in linux and remove a character based on a position for every record. It would highly appreciate if someone can help to automate this.

Appreciate your time and help!
Regards
# 2  
Old 02-01-2012
Show the input you have and the output you want please.
# 3  
Old 02-01-2012
Hello!

Below are the details -
Input:-
Record length is say 9 bytes

abcd1234@abcd1234@abcd@ xyzs1234@

We need to replace @ but only if it comes at the end of each record. Output that we are expecting should be
abcd1234abcd1234abcd@ xyzs1234

Thanks
# 4  
Old 02-01-2012
This might be a good place to start:

http://www.gnu.org/software/gawk/man...Functions.html
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Count specific character of a file in each line and delete this character in a specific position

I will appreciate if you help me here in this script in Solaris Enviroment. Scenario: i have 2 files : 1) /tmp/TRANSACTIONS_DAILY_20180730.txt: 201807300000000004 201807300000000005 201807300000000006 201807300000000007 201807300000000008 2)... (10 Replies)
Discussion started by: teokon90
10 Replies

2. Shell Programming and Scripting

Splitting based on occurence of a Character at fixed position

I have a requirement where i need to split a file based on occurence of a character which is present at a fixed position. Description is as below: 1. The file will be more than 1 Lakh records. 2. Each line will be of fixed length of 987 characters. 3. At position 28 in each line either 'C' or... (9 Replies)
Discussion started by: Neelkanth
9 Replies

3. UNIX for Dummies Questions & Answers

Change a character based on its position number

Hi I have a text file that I want to change some of the characters based on their position. My file contain multiple lines and characters should be counted continuously line by line. For example, I want to convert the 150th T to C. What can I do? Here is a portion of my file:... (10 Replies)
Discussion started by: a_bahreini
10 Replies

4. Shell Programming and Scripting

Remove " character from 25th position in file

Hi All, I want to remove " character if present in position 25th in CSV file. Each field in CSV file is separated by , and enclosed in "" (enclosed using double quotes) For example "1","2","3",........."123 Tom " is Good boy","26",........"45" Where "1" first position character, ...... 25th... (8 Replies)
Discussion started by: lancesunny
8 Replies

5. Shell Programming and Scripting

How to remove a semi-repeating character in position 1 of a file

My file is in a good column format but several lines in the file begin with a zero. I'm in KSH and looking for a command to remove this zero and keep the text next to it. I don't want any of the zeros in the other columns removed. Below is a snip from the file... all I need to do is remove that... (2 Replies)
Discussion started by: right_coaster
2 Replies

6. UNIX for Dummies Questions & Answers

Script to delete a word based on position in a file

Hi, I am new to unix. I want to delete 2 words placed at position say for example at 23rd and 45th position in a line. I used sed but couldnt achieve this. Example: the file contains 2 lines 12345 98765 "12345" 876 12345 98765 "64578" 876 I want to delete " placed at position 13 and 19... (4 Replies)
Discussion started by: nbks2u
4 Replies

7. Shell Programming and Scripting

Cut multiple data based on character position

How to extract multiple data based on character position. I need to fetch from 7-9 and 22-26 and there is no delimiter for 22-26 since it is part of the column. The file may have more than 1000 character long.I managed to pull any one but not both for example test data 12345 zxc vbnmlk... (1 Reply)
Discussion started by: zooby
1 Replies

8. Shell Programming and Scripting

Remove/Find files based on position pattern

Hi All, Please help me to find or remove files based on position based search pattern. file1.txt: aaabbbccc dddeeefff iiijjjkkk file2.txt: lllmmmnnn ooopppqqq rrrsssttt file3.txt: uuuvvvwww xxxeeeyyy zzzcccooo From the above files, I like to delete the files that have "eee"... (1 Reply)
Discussion started by: kumarn
1 Replies

9. Shell Programming and Scripting

Sorting a flat file based on multiple colums(using character position)

Hi, I have an urgent task here. I am required to sort a flat file based on multiple columns which are based on the character position in that line. I am restricted to use the character position instead of the space and sort +1 +2 etc to do the sorting. I understand that there is a previous... (8 Replies)
Discussion started by: cucubird
8 Replies
Login or Register to Ask a Question