Delete line till certain point


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Delete line till certain point
# 1  
Old 04-11-2008
CPU & Memory Delete line till certain point

Hi,

I have a requirement to delete a line till a certain word. Am not sure how to do it
e.g I want to delete till the bold character since start of line.

Any help is higly appretiated.
# 2  
Old 04-11-2008
Without knowing how the bold characters are encoded, we can only guess. There is no single unambiguous standard for this, but ANSI escape codes are probably a good guess.

A complexity is that the bold codes contain control characters, which cannot be typed here (and might be hard to type on your keyboard).

The general solution to this problem is to replace (with sed, for example) everything up to the string you want to find -- the bold code, in your case (if I understand correctly). As a proof of concept, try this:

Code:
sed 's/.*fnord//'

When you type something, if it contains the word "fnord", everything up to and including that word is removed. (Type ctrl-D to stop.)

Now, you want to do the same with the bold code as the magic word, but that is hard to type and hard to guess. But you could try asking the "tput" command to insert the bold code for you, so you don't even have to know what it is.

Try this:

Code:
sed "s/.*`tput smso`//" file

See the tput manual page for some other things to try if that doesn't work for you. Or if you know what the bold code is (maybe from looking at your file), see if you can copy+paste or type that in.
# 3  
Old 04-11-2008
era, thanks for the immediate help. When I said "bold" I just said it to point to a word and not bold as a special character.

Your solution worked.

Thanks again for the detailed help
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Bash script to read a file from particular line till required line and process

Hi All, Am trying to write wrapper shell/bash script on a utility tool for which i need to pass 2 files as arugment to execute utility tool. Wraper script am trying is to do with above metion 2 files. utility tool accepts : a. userinfo file : which contains username b. item file : which... (2 Replies)
Discussion started by: Optimus81
2 Replies

2. Shell Programming and Scripting

How to start reading from the nth line till the last line of a file.

Hi, For my reuirement, I have to read a file from the 2nd line till the last line<EOF>. Say, I have a file as test.txt, which as a header record in the first line followed by records in rest of the lines. for i in `cat test.txt` { echo $i } While doing the above loop, I have read... (5 Replies)
Discussion started by: machomaddy
5 Replies

3. Shell Programming and Scripting

Html parsing - get line after specific string till a point

Hi all :) It sounds complex, for example I want to find the whole html file (there are 5 entries of this string and I need to get all of them) for the string "<td class="contentheading" width="100%">", get the next line from it only till the point that says "</td>", plus removing \t (tabs) ... (6 Replies)
Discussion started by: hakermania
6 Replies

4. Shell Programming and Scripting

Bash take word after specific point and till next space?

Hello, I have an output like Interface Chipset Driver wlan0 Intel 4965/5xxx iwlagn - and I want to take only the 'wlan0' string. This can be done by a="Interface Chipset Driver wlan0 Intel 4965/5xxx iwlagn - " b=${a:25:6} echo $bThe thing is that wlan0 can be something else, like eth0 or... (2 Replies)
Discussion started by: hakermania
2 Replies

5. Shell Programming and Scripting

running a script only till a point in a day

how can i run the script if its less than a particular time only in unix. for e.g the script kicks off at 9AM and looks for some file etc. I want to make sure it runs only till 12PM and then succeed the job and proceed regardless if the file exists or not. how can we do this (1 Reply)
Discussion started by: dsravan
1 Replies

6. Shell Programming and Scripting

SED delete string from till problems

Hi i have a file which contains 2 lines, line 1 is static data. line 2 is a very large string(over 3000char or much more). in that string are tags which i want to delete. e.g. <order1>123</order1><tag1>data</tag1><new>1</new><order2>124</order2><tag1>data</tag1> all one one line. now i... (5 Replies)
Discussion started by: subby80
5 Replies

7. Shell Programming and Scripting

[Solved] Problem in reading a file line by line till it reaches a white line

So, I want to read line-by-line a text file with unknown number of files.... So: a=1 b=1 while ; do b=`sed -n '$ap' test` a=`expr $a + 1` $here do something with b etc done the problem is that sed does not seem to recognise the $a, even when trying sed -n ' $a p' So, I cannot read... (3 Replies)
Discussion started by: hakermania
3 Replies

8. Shell Programming and Scripting

delete strings till specific string

Hello i want to know a way so i can delete all the strings in file from the begning till a specific string (1 Reply)
Discussion started by: modcan
1 Replies

9. UNIX for Advanced & Expert Users

Urgent Help required : awk/sed help to find pattern and delete till end of line

Hi, I need help with using an awk or sed filter on the below line ALTER TABLE "ACCOUNT" ADD CONSTRAINT "ACCOUNT_PK" PRIMARY KEY ("ACCT_ID") USING INDEX PCTFREE 10 INITRANS 2 MAXTRANS 255 STORAGE(INITIAL 65536 FREELISTS 1 FREELIST GROUPS 1) TABLESPACE "WMC_DATA" LOGGING ENABLE Look for... (1 Reply)
Discussion started by: rajan_san
1 Replies

10. Shell Programming and Scripting

Urgent! Sed/Awk Filter Find Pattern Delete Till End Of Line

Hi, I need help with using an awk or sed filter on the below line ALTER TABLE "ACCOUNT" ADD CONSTRAINT "ACCOUNT_PK" PRIMARY KEY ("ACCT_ID") USING INDEX PCTFREE 10 INITRANS 2 MAXTRANS 255 STORAGE(INITIAL 65536 FREELISTS 1 FREELIST GROUPS 1) TABLESPACE "WMC_DATA" LOGGING ENABLE Look for... (2 Replies)
Discussion started by: rajan_san
2 Replies
Login or Register to Ask a Question