-1

This question already has an answer here:

currently I have faced a problem in changing a string in a file which have / character . I want to replace 1/0 with hetero in a file. can you tell me which command to use ?

marked as duplicate by Archemar, Stephen Kitt, heemayl, garethTheRed, Ulrich Schwarz Mar 29 '16 at 12:36

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • There are many ways to do this..can you add an example of your input file and your desired output from that.. – heemayl Mar 29 '16 at 12:01
  • is this some kind of home work ? replacing 1/0 or 0/1 with hetero ? – Archemar Mar 29 '16 at 12:03
  • 0/1:32 0/0:43 0/2:56 1/1:100 1/0:10 this is the file .. now I want to change the 0/1 with hetero so the new file would be 0/1:32 0/0:43 0/2:56 1/1:100 hetero:10 – user163263 Mar 29 '16 at 13:25
0

Try this:

sed 's;1/0;hetero;g' my_filename

  • this is showing the following error sed: -e expression #1, char 1: unterminated `s' command bash: 1/0: No such file or directory No command 'hetero' found, did you mean: Command 'hetro' from package 'csound-utils' (universe) hetero: command not found g: command not found – user163263 Mar 29 '16 at 13:29
  • @user163263 Are you sure you entered the above command including both single quotes? The error you indicated occurs if you omit the quotes. – Guido Mar 29 '16 at 16:13
  • I am sorry ... I have omitted the single quotes ... now it is working perfectly..Thank u so much .. but is there any way to replace the whole string with another string if they have have a common starting but different ending?? – user163263 Mar 30 '16 at 5:42
  • @user163263 Please provide an example for this. – Guido Mar 30 '16 at 10:56

Not the answer you're looking for? Browse other questions tagged or ask your own question.