Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-12-2002 11:19 PM
тАО08-12-2002 11:19 PM
I have a file called test.txt (1000 lines)in unix with cotents.
a.b
f.c
d.b
b.h
j.k
...
...
How can I delete a specific pattern example
j.k in this file by shell script.
regards,
U.SivaKumar
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-12-2002 11:39 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-12-2002 11:41 PM
тАО08-12-2002 11:41 PM
Re: script
What about grep -v '^j.k' test.txt ?
Or are you looking for more complex pattern matching?
Stanley.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-12-2002 11:42 PM
тАО08-12-2002 11:42 PM
Re: script
If this pattern is alone on a line:
grep -v j.k
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-12-2002 11:42 PM
тАО08-12-2002 11:42 PM
Re: script
#!/usr/bin/ksh
PATTERN=j.k
cat - << EOF | ed -s test.txt
/$PATTERN
d
w
q
EOF
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-13-2002 12:10 AM
тАО08-13-2002 12:10 AM
Re: script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-13-2002 07:09 PM
тАО08-13-2002 07:09 PM
Re: script
sed -e '/j.k/d' test.txt
In a script:
#!/usr/bin/ksh
eval sed -e '/$1/' test.txt
#end script
Then invoke as ./script.sh j.k
Cheers
Steven
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-13-2002 07:42 PM
тАО08-13-2002 07:42 PM
Re: script
#!/usr/bin/ksh
eval sed -e '/$1/d' test.txt
#end script
Then invoke as ./script.sh j.k
Steven
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-13-2002 08:11 PM
тАО08-13-2002 08:11 PM
Re: script
regards,
U.SivaKumar