Sponsored Content
Top Forums UNIX for Dummies Questions & Answers How to delete a particular word on particular line with sed? Post 302857211 by wisecracker on Wednesday 25th of September 2013 04:02:58 PM
Old 09-25-2013
Longhand using "sed" on OSX 10.7.5 default bash terminal:-
Code:
Last login: Wed Sep 25 20:44:33 on ttys000
AMIGA:barrywalker~> echo -e -n "NEW\nNEW\n/v/engine\nNEW\n/ifs/list\nNEW\n/ifs/vdrome\nNEW\n" > /tmp/txt
AMIGA:barrywalker~> sed '{1d;$d;}' < /tmp/txt
NEW
/v/engine
NEW
/ifs/list
NEW
/ifs/vdrome
AMIGA:barrywalker~> text=$(sed '{1d;$d;}' < /tmp/txt)
AMIGA:barrywalker~> echo -n "$text"
NEW
/v/engine
NEW
/ifs/list
NEW
/ifs/vdromeAMIGA:barrywalker~> echo "$text"    ####
NEW
/v/engine
NEW
/ifs/list
NEW
/ifs/vdrome
AMIGA:barrywalker~> _

NOTE: Newline is missing at line "####"...
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Sed help to delete everything prior to WORD

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)
Discussion started by: drheams
2 Replies

2. UNIX for Dummies Questions & Answers

Find a word and delete the line

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)
Discussion started by: gsusarla
1 Replies

3. UNIX for Advanced & Expert Users

Delete a word and complete line

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)
Discussion started by: Aejaz
1 Replies

4. Shell Programming and Scripting

delete line containin specified word

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)
Discussion started by: shawz
2 Replies

5. Shell Programming and Scripting

Sed or Grep to delete line containing patter plus extra line

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)
Discussion started by: rocketman88
2 Replies

6. Shell Programming and Scripting

SED to delete last word on line...what's wrong?

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)
Discussion started by: Bashingaway
2 Replies

7. UNIX for Dummies Questions & Answers

How to print line starts with specific word and contains specific word using sed?

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)
Discussion started by: tmalik79
11 Replies

8. UNIX for Dummies Questions & Answers

delete last word of each line a directory

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)
Discussion started by: A-V
8 Replies

9. Shell Programming and Scripting

sed command to grep multiple pattern present in single line and delete that line

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)
Discussion started by: vivek d r
14 Replies

10. UNIX for Beginners Questions & Answers

sed script to delete the last word after a last pattern match

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
ifs(6x) 							XScreenSaver manual							   ifs(6x)

NAME
ifs - draws spinning, colliding iterated-function-system images SYNOPSIS
ifs [-display host:display.screen] [-visual visual] [-window] [-root] [-no-db] [-delay number] [-detail number] [-colors number] [-func- tions number] [-iterate | -recurse] [-no-rotate] [-no-scale] [-no-translate] [-fps] DESCRIPTION
The ifs program draws spinning, colliding iterated-function-system images. OPTIONS
-visual visual Specify which visual to use. Legal values are the name of a visual class, or the id number (decimal or hex) of a specific visual. -window Draw on a newly-created window. This is the default. -root Draw on the root window. -no-db Disable double-buffering. -delay number Per-frame delay, in microseconds. Default: 20000 -colors number Number of colours to use. Default: 200 -detail number In -iterate mode, number of times to randomly iterate the functions, in thousands. In -recurse mode, number of times to apply functions (recursion depth) before drawing each point. Default: 9 -functions number Number of functions to be iterated. Default: 3 -iterate Calculate by iteratively applying the functions in a random order, usually faster than -recurse. This is the default. -recurse Calculate by recursively applying all combinations of the functions. This is the historical behavior and may produce neater output than -iterate. -no-rotate Disable the rotation component of the functions. -no-scale Disable the scaling component of the functions. -no-translate Disable the varying translation component of the functions. -no-multi Turn off multi-coloured mode, only one colour is used to colour the whole set. -fps Display the current frame rate and CPU load. ENVIRONMENT
DISPLAY to get the default host and display number. XENVIRONMENT to get the name of a resource file that overrides the global resources stored in the RESOURCE_MANAGER property. SEE ALSO
X(1), xscreensaver(1), ifs(6x) COPYRIGHT
Copyright (C) Chris Le Sueur and Robby Griffin, 2005-2006 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MER- CHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. AUTHOR
This version by Chris Le Sueur <thefishface@gmail.com>, Feb 2005 Many improvements by Robby Griffin <rmg@terc.edu>, Mar 2006 X Version 11 5.15 (28-Sep-2011) ifs(6x)
All times are GMT -4. The time now is 10:14 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy