- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: file maintenance
Categories
Company
Local Language
Forums
Discussions
Knowledge Base
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Forums
Discussions
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
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
07-13-2007 04:52 AM
07-13-2007 04:52 AM
bl002amcvt187.federated.fds 0x00A0F8651EAF 2
i know how to delete (.federated.fds) using sed, but how do i delete the ending 2 when this value changes, any help would be nice
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-13-2007 05:09 AM
07-13-2007 05:09 AM
Re: file maintenance
I assume, that by
>>
the ending 2 when this value changes
<<
you mean:
with a field delimiter 'space' the last field containing numbers only
Try
sed -e 's/[.]federated[.]fds / /' -e 's/ [0-9][0-9]*$//'
mfG Peter
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-13-2007 05:28 AM
07-13-2007 05:28 AM
Re: file maintenance
# perl -anle 'print join " ", @F[0..(scalar @F-3)]' file
...will delete the last TWO fields (zero-relative) of any number of fields (as separated by whitespace) in each line of a file.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-13-2007 05:32 AM
07-13-2007 05:32 AM
Re: file maintenance
Well, a bit more *obvious* is this way:
perl -anle 'print join " ", @F[0..($#F-2)]' file
# ...will delete the last TWO fields (zero-relative) of any number of fields (as separated by whitespace) in each line of a file.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-13-2007 05:54 AM
07-13-2007 05:54 AM
Re: file maintenance
sed 's/.federated.fds//g' /home/b009021/host2mac1,
what ending do i need to used to delete the ending value in this case a number 0-9 for this entry in this file ie
before using sed
bl004amcvt031.federated.fds 0x00A0F83CD702 2
after sed
bl004amcvt031 0x00A0F83CD702 2
I still need to delete the 2
any ideas
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-13-2007 06:27 AM
07-13-2007 06:27 AM
Re: file maintenance
sed -e 's/[.]federated[.]fds / /' -e 's/ [0-9]$//'
Regards,
Ninad
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-13-2007 07:00 AM
07-13-2007 07:00 AM
Re: file maintenance
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-13-2007 07:27 AM
07-13-2007 07:27 AM
Re: file maintenance
sed -e 's/\.federated\.fds //' -e 's/ [0-9] *$//' < infile > outfile
This will match a single digit separated from the preceding data by a space and followed by zero or more spaces at the end of the line.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-13-2007 08:41 AM
07-13-2007 08:41 AM
Re: file maintenance
This will delete the single digit on ALL lines.
Is this what Anthony wants?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-13-2007 09:19 AM
07-13-2007 09:19 AM
Re: file maintenance
Along the lines of Clay's thinking, perhaps *whitespace* (spaces and/or tabs) trails the last digit:
# sed -e 's/\.federated\.fds / /' -e 's/[0-9][ ]*$//' file > file.out
Note that the forum doesn't render spaces and/or tab characters nor the number thereof. Within the seemingly empty "[ ]" I typed a *space* and hit the *tab* key.
I'm sorry for not reading your original requirement better. I mistook "...delete the ending 2..." to mean "delete the ending 2 FIELDS...".
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-13-2007 09:35 AM
07-13-2007 09:35 AM
Re: file maintenance
additionally or instead of a space/TAB at the end of the line (after the ' 2') it may be, that there is a CR+LF at the end of the line (being a DOS borne file).
If you attach - perhaps only a part - of your input data we can verify this.
Extending my assumption about 'the ending' to:
"a field delimiter may be a TAB or space" I tend to some awk like this:
awk '/.federated.fds/ {sub("[.]federated[.]fds",""); printf $1;
for(i=2;i
mfG Peter
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-13-2007 10:42 AM
07-13-2007 10:42 AM
Re: file maintenance
sed -e 's/\(.*\)\(\.federated\.fds \)\(.*\)\( [0-9] *$\)/\1 \3/' < infile > outfile
It's using RE grouping \(...\) to grab everything before ".federated.fds " into group 1, and everything before the last space separated digit into group 3 and then substituting the saved group 1, a space, and group 3 for the line. Note that there are 4 RE Groups but we only want 2 of them when the entire RE is matched otherwise the line goes through unchanged.
If you want to filter out possible CR's in the input then the simplest way would probably be to use tr to feed this thing.
tr -d "\r" < infile | sed -e 's/\(.*\)\(\.federated\.fds \)\(.*\)\( [0-9] *$\)/\1 \3/' > outfile
Now tell me that ain't some ugly sed but it should work. I've carefully looked over the logic/syntax but not executed it.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-13-2007 10:56 AM
07-13-2007 10:56 AM
Re: file maintenance
do2ux(1) is made to do just that.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-13-2007 11:01 AM
07-13-2007 11:01 AM
Re: file maintenance
>Clay: If you want to filter out possible CRs
dos2ux(1) is made to do just that.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-13-2007 11:18 AM
07-13-2007 11:18 AM
Re: file maintenance
At this point it would be most helpful if you posted representative lines from the file. In fact, posting :
# xd -tcx file
...output would settle the questions of whitespace and line endings (whitespace, LF, CRLF).
Are you committed to 'sed'? The syntax becomes clumsy and it's regular expressions are not as powerful nor easily deployed as Perl's as/if data becomes more variable and complex.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-16-2007 01:02 AM
07-16-2007 01:02 AM
Re: file maintenance
Anthony
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-16-2007 05:10 AM
07-16-2007 05:10 AM
Re: file maintenance
38093078 30303042 36433136 38374133
0007f80 \t 2 \n m c 2 1 3 a m c v t 1 0 8
9320a6d 63323133 616d6376 74313038
0007f90 \t 0 x 0 0 1 0 2 0 0 0 3 B 9 1 \t
9307830 30313032 30303033 42393109
0007fa0 2 \n m c 2 1 3 a m c v t 1 0 9 \t
320a6d63 32313361 6d637674 31303909
here you go, thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-16-2007 05:14 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-16-2007 06:52 AM
07-16-2007 06:52 AM
Re: file maintenance
tr "\t" " " < infile | sed -e 's/\(.*\)\(\.federated\.fds \)\(.*\)\( [0-9] *$\)/\1 \3/' > outfile
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-16-2007 07:16 AM
07-16-2007 07:16 AM
Re: file maintenance
sed 's/.federated.fds//g' /home/b009021/host2mac1 | awk '{print $1" "$2}' > /ho
me/b009021/host2mac2
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-16-2007 07:17 AM
07-16-2007 07:17 AM
Re: file maintenance
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-16-2007 07:18 AM
07-16-2007 07:18 AM
Re: file maintenance
me/b009021/host2mac2