Replace a perticular character of all lines of a file

Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Replace a perticular character of all lines of a file
# 1  
Old 12-11-2007
Replace a perticular character of all lines of a file

Hi all,

I am new to UNIX, so sorry if my question seem stupid to u.

well i want to replace the first character of first 30 lines of a file, only if the first character is h.


in anothe script i want to replace a particular string/character say hello/h of a file.Condition: It should replace all Hello/h in the first line where it is found and after that it should stop.

# 2  
Old 12-11-2007
hey experts,

please give the solution!
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Replace the perticular fileds in passwd file

Hi I have 2 different password entries in 2 different files for the same user. file 1 - siva:correct:1000:23:siva:/home/siva:/bin/bash file 2 - siva:incorrect:1000:23:siva:/home/siva:/bin/bash file 1 is having correct passwd entry where as file 2 is wrong. Now, i want to compare... (3 Replies)
Discussion started by: kumar85shiv
3 Replies

2. Shell Programming and Scripting

Replace character in a file.

I have a data like this in a file. 05/08/2017,U,01,116326001 05/08/2017,U,01,116226001 05/08/2017,U,01,116726323 05/08/2017,U,01,116236001 I want replace the date(1st column) of all records. Ex: 05/08/2017 to 04/02/2017 Please use CODE tags when displaying sample input, sample output,... (1 Reply)
Discussion started by: Artlk
1 Replies

3. UNIX for Dummies Questions & Answers

Replace character in odd or even lines

Hello, I'm here again asking for your precious help. I'm writing some code to convert csv files to html. I want to highlight header and also I want to have rows with alternate colors. So far this is my work###Let's format first line only with some color cat $fileIN".tmp1" | sed '1... (7 Replies)
Discussion started by: emare
7 Replies

4. Shell Programming and Scripting

Search a character and replace it with multiple lines

This is for AIX 6.1, I've a flat file and the format is like this DECLARE some statements; BEGIN some statements; END; I've to search BEGIN and replace it with the following 4 lines BEGIN For x in 1..1 LOOP BEGIN Similarly I've to search END and replace it with the... (7 Replies)
Discussion started by: Mukul Sharma
7 Replies

5. Emergency UNIX and Linux Support

Replace nth position character of all the lines in file

I want to replace 150th character of all the lines in a file using sed or awk... searched the forums but didn't find exact answer (9 Replies)
Discussion started by: greenworld123
9 Replies

6. Shell Programming and Scripting

Replace a character in a file

Hello, Can anyone help me? I need to replace the letters (A, B, C..) of the second column in this file by a number i.e. 1. current file 0123456 0A123 0003355 Marion 1234567 0B117 0003388 Anthony 1112333 0C345 0459877 Ann new file 0123456 01123 0003355 Marion 1234567 ... (3 Replies)
Discussion started by: Lilu_CK
3 Replies

7. Shell Programming and Scripting

Replace last character in file

Greetings UNIX folks, I am running a tcsh script and trying to replace the last character of a file with the number 0. I know that the last character of the file will always be 1, but I only want to replace the last character. Example: 78062 26.55 78.77 1 MYGF1 24.89 15.78 1 ... (2 Replies)
Discussion started by: TheSMan5
2 Replies

8. Shell Programming and Scripting

read in a file character by character - replace any unknown ASCII characters with spa

Can someone help me to write a script / command to read in a file, character by character, replace any unknown ASCII characters with space. then write out the file to a new filename/ Thanks! (1 Reply)
Discussion started by: raghav525
1 Replies

9. Shell Programming and Scripting

How to replace a character in the file?

Hi All, I have file contains the following information. ] Critical 3/21 ] Normal 3/22 ] Normal 3/23 ] Normal 3/24 ] Critical 3/25... (2 Replies)
Discussion started by: ntgobinath
2 Replies

10. Shell Programming and Scripting

extract perticular lines and make them into speadsheet

Hi Masters, I knew this isn't a new issue, but couldn't find any similar threads. So, I have to bother you. Here is my input file (genomic data). The file has many sessions, each session seperated by //. Within eash session there is only one ID and GN line. ID 3HAO_HUMAN STANDARD; ... (4 Replies)
Discussion started by: mskcc
4 Replies
Login or Register to Ask a Question