How to delete a particular word on particular line with sed?
I have a file from which I am trying to delete a particular word on a particular line.
I am trying to delete the first line only if it contains the word NEW. I am also trying to delete the last line only if it contains the word NEW. I don't want any other lines deleted. I have tried
but that deletes more than the first line. I've also tried
but I don't care for that command as it would delete even if the word was not NEW.
It is going to be used on multiple files in a script and I need to make sure that no matter what is in between the last NEW and the first NEW are always deleted. And the words on the first and last line will not always be "NEW."
How would I delete everything on a line in a file prior to a specific word?
In other words, I have a file that contains the word SEARCH on various lines and would like to delete everything prior to SEARCH on all lines. Thanks for that help (2 Replies)
Hi I have a text file like this name today.txt
the request has been accepted
the scan is successful at following time
there are no invalid packages
5169378 : map : Permission Denied
the request has been accepted
Now what i want do is
I want to search the today.txt file and
if i... (1 Reply)
Hi Canone please provide me solution how can achieve the result below:
File1.txt
$
sweet appleŁ1
scotish
green
$
This is a test1
$
sweet mangoŁ2
asia
yellow
$
This is a test 2
$
sweet apple red (there is no pound symbol here)
germany
green (1 Reply)
write a shell script that deletes all lines containing a specified word in one or more files supplied as arguments to it.help is appreciated .thank you. (2 Replies)
I'm new to using sed and grep commands, but have found them extremely useful. However I am having a hard time figuring this one out:
Delete every line containing the word CEN and the next line as well.
ie. test.txt
blue
324 CEN
green
red
blue
324 CEN
green
red
blue
to produce:... (2 Replies)
I have a line that gets pulled from a database that has a variable number of fields, fields can also be of a variable size. Each field has a variable number of spaces between them so there is no 'defined' delimiter. The LastData block is always a single word.
What I want to do is delete the... (2 Replies)
Hi,
I have gone through may posts and dint find exact solution for my requirement.
I have file which consists below data and same file have lot of other data.
<MAPPING DESCRIPTION ='' ISVALID ='YES' NAME='m_TASK_UPDATE' OBJECTVERSION ='1'>
<MAPPING DESCRIPTION ='' ISVALID ='NO'... (11 Replies)
I want to delete the last word of each line in all the files in one directory but dont know what I am doing wrong
FILES="data/*"
for X in $FILES
do
name=$(basename $X)
sed s/'\w*$'// $X > no-last/${name}
done
Can you please help me :wall: (8 Replies)
here is what i want to achieve.. i have a file with below contents
cat fileName
blah blah blah
.
.DROP this
REJECT that
.
--sport 7800 -j REJECT --reject-with icmp-port-unreachable
--dport 7800 -j REJECT --reject-with icmp-port-unreachable
.
.
.
more blah blah blah
--dport 3306... (14 Replies)
Hi Guys ,
I am having a file as stated below
File 1
sa0 -- i_core/i_core_apb/i_afe0_controller/U261/A
sa0 -- i_core/i_core_apb/i_afe0_controller/U265/Z
sa1 -- i_core/i_core_apb/i_afe0_controller/U265/A
sa1 -- i_core/i_core_apb/i_afe0_controller/U268/Z
sa1 -- ... (7 Replies)
Discussion started by: kshitij
7 Replies
LEARN ABOUT DEBIAN
mtp_objects
The object management API.(3) libmtp The object management API.(3)NAME
libmtp - The object management API.
Functions
int LIBMTP_Delete_Object (LIBMTP_mtpdevice_t *, uint32_t)
int LIBMTP_Set_Object_Filename (LIBMTP_mtpdevice_t *, uint32_t, char *)
Detailed DescriptionFunction Documentation
int LIBMTP_Delete_Object (LIBMTP_mtpdevice_t *device, uint32_tobject_id)
This function deletes a single file, track, playlist, folder or any other object off the MTP device, identified by the object ID.
If you delete a folder, there is no guarantee that the device will really delete all the files that were in that folder, rather it is
expected that they will not be deleted, and will turn up in object listings with parent set to a non-existant object ID. The safe way to do
this is to recursively delete all files (and folders) contained in the folder, then the folder itself.
Parameters:
device a pointer to the device to delete the object from.
object_id the object to delete.
Returns:
0 on success, any other value means failure.
References LIBMTP_mtpdevice_struct::params.
int LIBMTP_Set_Object_Filename (LIBMTP_mtpdevice_t *device, uint32_tobject_id, char *newname)
THIS FUNCTION IS DEPRECATED. PLEASE UPDATE YOUR CODE IN ORDER NOT TO USE IT.
See Also:
LIBMTP_Set_File_Name()
LIBMTP_Set_Track_Name()
LIBMTP_Set_Folder_Name()
LIBMTP_Set_Playlist_Name()
LIBMTP_Set_Album_Name()
References LIBMTP_file_struct::filetype, and LIBMTP_Get_Filemetadata().
Author
Generated automatically by Doxygen for libmtp from the source code.
Version 1.1.3 Sun Feb 17 2013 The object management API.(3)