03-17-2010
Delete everything after/before a word in a file
I'm looking for a command that will read a file listing information and delete everything after a certain word is found. I also may need to search the file and delete everything before a certain word. The file would contains fields of information like below repeating for the entire file;
Name
Title
Loacation
DOB
phone number
hire date
I'd want to parse the file find an entry and delete everything after the hire date for the pitcular entry leaving everything before it. I also may need to parse the file find an entry and delete everything before the Name leaving everything after it.
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Hi All,
I want to delete a word from file. How to do that.
I have file that contains the following Information.
EntityName:alba00r1.mis.amat.com OverallStatus:Minor IfName:Gi1/0
EntityName:alba00r1.mis.amat.com ] OverallStatus:Normal IfName:Se0/0/0... (4 Replies)
Discussion started by: ntgobinath
4 Replies
2. UNIX for Dummies Questions & Answers
i have created the following input script
CREATE OR REPLACE VIEW MMSSENDAVGUPLOADTIME_GN
AS
sp_strip_mean_value_type.get_val(MMSSENDAVGUPLOADTIME) MMSSENDAVGUPLOADTIME_val
sp_strip_mean_value_type.get_val(MMSSENDAVGUPLOADTIME) MMSSENDAVGUPLOADTIME_counter
select... (1 Reply)
Discussion started by: gseptember
1 Replies
3. Shell Programming and Scripting
Hi expert,
I am using C shell. And i trying to delete repeated word.
Example file.txt:
BLUE
YELLOW
RED
VIOLET
RED
RED
BLUE
WHITE
YELLOW
BLACK
and i wan store the output into a new file:
BLUE (6 Replies)
Discussion started by: vincyoxy
6 Replies
4. Shell Programming and Scripting
Hi,
I need to find a word in a file, and I need to delete the file where the word resides on the file.
I did try with the grep -H "word" using the find command, but no luck. (6 Replies)
Discussion started by: gsiva
6 Replies
5. Shell Programming and Scripting
Friends, I'm looking for a command that delete the first tho caractere in a word. Here is an exp :
I want to replace "20091001" by "091001"
or "replace" by "place"
Thx, (13 Replies)
Discussion started by: newpromo
13 Replies
6. Shell Programming and Scripting
Hi All,
I have a file with the data as below. In this i want to delete the last word. Could you pls help me.
$INSTALL_HOME/lib/fm_voucher_pol.so
$INSTALL_HOME/source/sys/fm_apn_pol/fm_apn_pol_device_set_state.c
In the above two lines i want to delete fm_voucher_pol.so and... (5 Replies)
Discussion started by: girish.raos
5 Replies
7. UNIX for Dummies Questions & Answers
Hi,
I am new to unix. I want to delete 2 words placed at position say for example at 23rd and 45th position in a line. I used sed but couldnt achieve this.
Example: the file contains 2 lines
12345 98765 "12345" 876
12345 98765 "64578" 876
I want to delete " placed at position 13 and 19... (4 Replies)
Discussion started by: nbks2u
4 Replies
8. Shell Programming and Scripting
Hi,
I have to search a word in a text file and then I have to delete lines above from the word searched . For eg suppose the file is like this:
Records
P1
10,23423432
,77:1
,234:2
P2
10,9089004
,77:1
,234:2
,87:123
,9898:2
P3
456456
P1
:123,456456546
P2
abc:324234 (2 Replies)
Discussion started by: vsachan
2 Replies
9. Shell Programming and Scripting
HI Guys,
I have Input:- A
nput A.txt
000100/port_xcu_dev_6/port_0_dev_7
000100/port_xcu_dev_6/port_1_dev_10
000100/port_xcu_dev_2/port_2_dev_8
000100/port_xcu_dev_3/port_3_dev_11
000100/port_xcuv_9/port_4_dev_9 ... (3 Replies)
Discussion started by: pareshkp
3 Replies
10. Shell Programming and Scripting
My file has contents like below. It is named as output_file.txt
/usr/sas/sas_config/Lev1/SASApp/StoredProcessServer/Logs/SASApp_STPServer_2015-08-27_tmptcmsaslva2_19142.log
/usr/sas/sas_config/Lev1/SASApp/StoredProcessServer/Logs/SASApp_STPServer_2015-08-27_tmptcmsaslva2_19142.log... (12 Replies)
Discussion started by: Ram Kumar_BE
12 Replies
ANNO(1) [nmh-1.5] ANNO(1)
NAME
anno - annotate messages
SYNOPSIS
anno [+folder] [msgs] [-component field] [-inplace | -noinplace] [-date | -nodate] [-draft] [-append] [-list] [-delete] [-number [num|all]]
[-preserve | -nopreserve] [-version] [-help] [-text body]
DESCRIPTION
Anno manipulates header fields or annotations in messages. Header fields consist of a field name and an optional field body as defined by
RFC-2822. The -component option specifies the field name, and the -text option specifies the field body.
The messages are either the msgs in the named folder, or the draft if invoked with the -draft option.
Usually, annotation is performed by the commands dist, forw, and repl, if they are given the -anno switch. This allows you to keep track
of your distribution of, forwarding of, and replies to a message.
By using anno, you can perform arbitrary annotations of your own. Each message selected will be annotated with the lines
field: date
field: body
The -nodate switch inhibits the date annotation, leaving only the body annotation.
By default, anno prepends the annotations to the message. Annotations are instead appended if the -append option is specified.
If a -component field is not specified when anno is invoked, anno will prompt the user for the name of field for the annotation.
The field specified must be a valid 2822-style message field name, which means that it may only consist of alphanumerics and dashes, The
body specified is arbitrary text.
Normally anno does the annotation inplace in order to preserve any links to the message. You may change this by using the -noinplace
switch.
The -list option produces a listing of the field bodies for header fields with names matching the specified component, one per line. The
listing is numbered, starting at 1, if the -number option is also used. A tab character separates the number and the field body. The
field body is treated as if it is a file name, and only the final path name component is listed. The complete field body is listed if the
-text option is used, the contents of the text are ignored.
The -delete option removes header fields from messages. The first header field whose name matches the component is deleted if no other
options are specified. If the -text option is used in conjunction with the -delete option, the first header field whose name matches the
component and whose body matches the text is deleted. The text is treated as if it was a file name; if it begins with a slash, the entire
field body must match the text, otherwise just the last path name component of the field body must match. If the -number option is used in
conjuction with the -delete option, header field num whose name matches the component is deleted. The number matches that which is pro-
duced by the -list option. The special value all can be used for the number, and causes all components that match the name to be deleted.
By default, anno changes the last-accessed and last-modified times on annotate messages to the time at which the annotation occurs. Anno
preserves the original times if the -preserve option is used. A matching -nopreserve option exists that allows time preservation to be
turned off if enabled in the profile.
FILES
$HOME/.mh_profile The user profile
PROFILE COMPONENTS
Path: To determine the user's nmh directory
Current-Folder: To find the default current folder
SEE ALSO
dist(1), forw(1), repl(1)
DEFAULTS
`+folder' defaults to the current folder
`msgs' defaults to cur
`-inplace'
`-date'
CONTEXT
If a folder is given, it will become the current folder. The first message annotated will become the current message.
MH.6.8 11 June 2012 ANNO(1)