using sed to add letter after variable


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting using sed to add letter after variable
# 1  
Old 02-04-2008
Error using sed to add letter after variable

Hi All,

I need to have a sed command insert the letter i at the end of some lines in a file.

Problem is that where I want to add the i is after variables that change in each file

eg, tsal314384'
tsal315386'
tsal317392'

I need to have it like this

tsal314384i'
tsal315386i'
tsal317392i'

so the problem is that the six numbers at the end of the line are never the same. Can anyone help ?

Jeremy
# 2  
Old 02-04-2008
Try this. It places 'i' before the single quote at the end of your lines per your example

Code:
sed  "s/\'$/i'/g" file

# 3  
Old 02-04-2008
Error

hi fpmurpy

Thanks for getting onto it so quick.

This has worked to some extent but now I have this problem

tsal314384'i' instead of tsal314384i'

Do you know what is happening here.

Jeremy
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Awk/sed - add space between dot and letter

I need to change . into . so that e.g. A.Jbecomes A. JI have tried sed 's/\./\.\ /g' but that didn't work. (9 Replies)
Discussion started by: locoroco
9 Replies

2. Shell Programming and Scripting

Setting letter as variable

I need to pass letter like "c" for "-copy" and need to read by variable $sel_mod, My I know the good way of writing the script. Example: Select one of the Clone Mode ( '-copy', '-differential', '-precopy', '-nopcopy') Type the Clone mode : c Thanks in advance, Ashan ... (6 Replies)
Discussion started by: ashanabey
6 Replies

3. Shell Programming and Scripting

SED (or other) upper to lowercase, with first letter of first word in each sentence uppercase

The title pretty much defines the problem. I have text files that are all in caps. I would like to convert them to lowercase, but have the first letter of the first word in each sentence in uppercase. I already have SED on the server for fixing / tweaking text files, but I'm open to other... (5 Replies)
Discussion started by: dockline
5 Replies

4. Shell Programming and Scripting

Remove letter from $1 using awk or sed

I have a file: 575G /local/mis/SYBDUMP I want to remove the G, K, M or T so I can use $1 in awk or sed to do math. I want to end up with a file containing: 575 /local/mis/SYBDUMP It should not matter how small or large the numeric numbers are so if 2, 3, 4, or 5 digits etc I want to see... (9 Replies)
Discussion started by: tamvgi
9 Replies

5. Shell Programming and Scripting

Get letter from number and assign to a variable

Hi to all in forum, I'm trying to convert the letter number between 1 (A) and 26 (Z), that part is working, my issue is how to assign the printf output to a variable:LetterNumber=10 printf "\x$(printf %x $((${LetterNumber}+64)))" $ J #The problem, how to assign printf output (J in this... (8 Replies)
Discussion started by: Ophiuchus
8 Replies

6. Shell Programming and Scripting

Trying to take a string and break each letter into a separate variable

I am trying to make a script that takes a word and each letter up and turns it into a separate variable. My code currently does not work but I feel I just need to tweak one thing that I am unsure of. (ex: if forum was typed in letter1=f; letter2=o; letter3=r;...) Thank you count=1; ... (7 Replies)
Discussion started by: crimputt
7 Replies

7. Shell Programming and Scripting

HOWTO - change letter case of variable value

Hi I have e.g. VAR1=january and I need to change it into VAR1=January. How to change value of VAR1 variable to always set first character uppercase and other lowercase ? thx for help. (9 Replies)
Discussion started by: presul
9 Replies

8. Shell Programming and Scripting

Set the last 4 letter in the filename as a variable

Hi all, I want to set the last 4 letter in the filename as a variable. For example, i have AB1234.txt file and i need to have last 4 letter as a variable. It should be like ; get last four letter set var = 1234 How can i write this in C shell?? Thanks, zibi (3 Replies)
Discussion started by: zibi
3 Replies

9. Shell Programming and Scripting

Trying to capitalize first letter of every word in Variable

Total Bash noob, have been successful in doing my script by searching and looking at examples, but I need some assitance with this one, just can't figure it out. In the Bash script I am trying to capitalize the first letter of every word in a string, ideally not changing other capitalization. ... (5 Replies)
Discussion started by: randyharris
5 Replies

10. UNIX for Advanced & Expert Users

how to read each letter from file and store it in variable.

Dear friends, i am writing csh script i have one dat file containing following data.like this. 08FD3 03A26 000FA0 FFFF0 BBA0F 00000 00000 from the above file i want to read each letter and store it in one variable. how it is possible. please help (7 Replies)
Discussion started by: rajan_ka1
7 Replies
Login or Register to Ask a Question