GreenLake Administration
- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- rows for which the last letter ends
Operating System - HP-UX
1848459
Members
8227
Online
104029
Solutions
Forums
Categories
Company
Local Language
back
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Forums
Discussions
back
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
Discussion Boards
Blogs
Information
Community
Resources
Community Language
Language
Forums
Blogs
Go to solution
Topic Options
- 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-25-2004 12:53 AM
08-25-2004 12:53 AM
Please help me out
I want a unix shell script command to do the following:
- Read this x1.txt and create 3 separate files a.dat, b.dat and
c.dat
- a.dat should have all the rows for which the last letter ends
with
"A"
- b.dat should have all the rows for which the last letter ends
with
"D"
- c.dat should have all the rows for which the last letter ends
with
"C"
Thanks
I want a unix shell script command to do the following:
- Read this x1.txt and create 3 separate files a.dat, b.dat and
c.dat
- a.dat should have all the rows for which the last letter ends
with
"A"
- b.dat should have all the rows for which the last letter ends
with
"D"
- c.dat should have all the rows for which the last letter ends
with
"C"
Thanks
Solved! Go to Solution.
3 REPLIES 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-25-2004 01:23 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-25-2004 01:34 AM
08-25-2004 01:34 AM
Re: rows for which the last letter ends
The simple multiple greps should do.
But if somehow (pipe!) you can only go over the data once, then you coudl use perl or awk like so:
awk 'BEGIN {f["A"]="a.dat";f["D"]="b.dat";f["C"]="c.dat"} {print $0 >> f[substr($0,length($0))]}' all.dat
Hein.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-25-2004 01:53 AM
08-25-2004 01:53 AM
Re: rows for which the last letter ends
We can identify the pattern on a file which occurs on the input file with $
Example:
x1.txt
------
power script eA
bye for now
Test enviginee yeB
ncie choke C
test byeD
over
grep 'A$' x1.txt > a.dat
grep 'D$' x1.txt > b.dat
grep 'C$' x1.txt > c.dat
You can get multiple patterns as,
grep 'A$|B$' x1.txt > ab.txt
HTH.
+Muthu+
Example:
x1.txt
------
power script eA
bye for now
Test enviginee yeB
ncie choke C
test byeD
over
grep 'A$' x1.txt > a.dat
grep 'D$' x1.txt > b.dat
grep 'C$' x1.txt > c.dat
You can get multiple patterns as,
grep 'A$|B$' x1.txt > ab.txt
HTH.
+Muthu+
Easy to suggest when don't know about the problem!
The opinions expressed above are the personal opinions of the authors, not of Hewlett Packard Enterprise. By using this site, you accept the Terms of Use and Rules of Participation.
Company
Events and news
Customer resources
© Copyright 2026 Hewlett Packard Enterprise Development LP