Adding a character

Hi,

I cant seem to figure out how I add a character to an existing one. Heres my problem.

So I have a line that looks like this:

>56
584848392394958586858484849393

What I want to do is add Num in front of the 56. So basically I want to recognize the > and add Num in front of the number.

I guess the same scenario would be to add Num to a column.

So I have a column that looks like this:

56
54
43

What what I want to do is add Num to all of them, so it will look like this:

Num56
Num54
Num43

Thanks

that can be done in many ways simpler to uae awk

awk '/^>/{gsub(">","NUM")}{print}' filename

Hey that command worked but I made a mistake. Sorry

So want it to add Num in front of the number but also keep the >

So the final output would look like this

>Num56
4757474834848

then use sed its more easy

sed 's/^\(>\)\([0-9]*\)/\1num\2/g' filename

works like a charm! :slight_smile:

-----Post Update-----

What if I wanted to add Num to every row on a column:

So lets say my column looks like this

56
45
45
43
23
45

I want to add Num in front of all the numbers for column 1.

Num56
Num45
Num45
Num43
Num23
Num45

thanks

the common way to add something in front of a line is to print them out. pseudocode:

for line in file
  print "num" , line

you can use awk, bash's while read loop etc to iterate files.

common give it a try refer awk man page
if not possible revert back we will definately help you..