copying to the end of the line

Thread Tools Search this Thread
Top Forums Shell Programming and Scripting copying to the end of the line
# 8  
Old 09-19-2011
sed 's#><!\[I]]></#/>#' yourfile

only the opening square backet must be escaped (escaping the closing bracket is useless)

$ cat f1
<A="B/C/D"/><E="F" G="H"><![I]]></
$ sed 's#><!\[I]]></#/>#' f1
<A="B/C/D"/><E="F" G="H"/>

# 9  
Old 09-19-2011
Originally Posted by michaelrozar17
Through Sed..
sed 's/\([a-z][a-z0-9]*>\).*/&\1/' inputfile

could you explain how this command works?
Especially this part "&\1".
# 10  
Old 09-19-2011

the & refer to what has previously been matched in the whole pattern space (here within the first /.../ )

This example would put the third column at the firt column:

The \1 refer to what has previously been matched in the first parenthesis of the pattern space \(...\)
This User Gave Thanks to ctsgnb For This Post:
# 11  
Old 09-19-2011
I'm having a little trouble, this is my fault as i got the code slightly wrong

line number <A="B/C/D"/><E="F" G="H"><![[I]]></

I forgot to mention the line number is in it which i need keeping and also there is an extra [ in the last string. I have tried everything I can think of from editing what I was given to trying my own code.
Is there anything else you can think of??
# 12  
Old 09-19-2011
echo '123 <A="B/C/D"/><E="F" G="H"><![[I]]></' | sed -e 's#><!\[\[I]]>.*$#/>#g' -e 's#/>#>#1'

# 13  
Old 09-19-2011
Still not quite there Smilie

I don't think ive been incredibly clear thats my fault but the A B C etc are not actually that in the file I need the script to be able to work when these are different each time
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Printing string from last field of the nth line of file to start (or end) of each line (awk I think)

My file (the output of an experiment) starts off looking like this, _____________________________________________________________ Subjects incorporated to date: 001 Data file started on machine PKSHS260-05CP ********************************************************************** Subject 1,... (9 Replies)
Discussion started by: samonl
9 Replies

2. Shell Programming and Scripting

With script bash, read file line per line starting at the end

Hello, I'm works on Ubuntu server My goal : I would like to read file line per line, but i want to started at the end of file. Currently, I use instructions : while read line; do COMMAND done < /var/log/apache2/access.log But, the first line, i don't want this. The file is long... (5 Replies)
Discussion started by: Fuziion
5 Replies

3. Shell Programming and Scripting

How to set end limit while copying files of a range??

I have files being generated in format A20140326.00........ to A20140326.24............. I need to copy these hourly basis from one location to another. Eg. If i copy from 14 to 19 the hour, I use wildcard as A201403226.1*. Requirement is : I need to copy from 06 hour and wil run the script... (1 Reply)
Discussion started by: Saidul
1 Replies

4. UNIX for Dummies Questions & Answers

vim copy line and paste at the beginning, middle, and end of another line

How would you do vim copy line and paste at the beginning, middle, and end of another line. I know yy copies the whole line and p pastes the whole line, but on its own separate line. Sometimes I would like to copy a line to the beginning, middle, or end of another line. I would think this would be... (3 Replies)
Discussion started by: cokedude
3 Replies

5. UNIX for Dummies Questions & Answers

How to specify beginning-of-line/end-of-line characters inside a regex range

How can I specify special meaning characters like ^ or $ inside a regex range. e.g Suppose I want to search for a string that either starts with '|' character or begins with start-of-line character. I tried the following but it does not work: sed 's/\(\)/<do something here>/g' file1 ... (3 Replies)
Discussion started by: jawsnnn
3 Replies

6. Shell Programming and Scripting

find a certain line and append text to the end of the line

After I create printer queues in AIX, I have to append a filter file location within that printers custom file. within lets say test_queue.txt I need to find the row that starts with :699 and then I need to append on the end the string /usr/local/bin/ Now I've gotten the sed... (2 Replies)
Discussion started by: peachclift
2 Replies

7. Programming

concatinate all lines from second line to end of line in perl

I have datafile like ~dta.yunm shhshsgggssssjsksjs sggsjshsjsjssss shshshhshshshs i wish to take only first line and all other lines in concatenated form in second line what should I do??? output like ~dta.yunm shhshsgggssssjsksjssggsjshsjsjssssshshshhshshshs please tell me how... (7 Replies)
Discussion started by: sujit_singh
7 Replies

8. Shell Programming and Scripting

Get the 1st 99 characters and add new line feed at the end of the line

I have a file with varying record length in it. I need to reformat this file so that each line will have a length of 100 characters (99 characters + the line feed). AU * A01 EXPENSE 6990370000 CWF SUBC TRAVEL & MISC MY * A02 RESALE 6990788000 Y... (3 Replies)
Discussion started by: udelalv
3 Replies

9. Shell Programming and Scripting

Copying x words from end of line to specific location in same line

Hello all i know it is pretty hard one but you will manage it all after noticing and calculating i find a rhythm for the file i want to edit to copy the last 12 characters in line but the problem is to add after first 25 characters in same line in other way too copy the last 12 characters... (10 Replies)
Discussion started by: princesasa
10 Replies

10. Shell Programming and Scripting

copying from line N1 to line N2 of a file in a series of files

Dear community, I'm quite a newbie with scripting, I have this problem: I have a file with many lines and I want to copy the lines from 1 to N to file.1, from N+1 to 2N to file.2, and so on up to the end of the file I have tried with something like this (N=43 in this example): awk '{for... (2 Replies)
Discussion started by: paolalup
2 Replies
Login or Register to Ask a Question