- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Help with script to edit a text file
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
Forums
Discussions
Discussions
Discussions
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
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
04-14-2003 03:48 AM
04-14-2003 03:48 AM
DISK$MMCP1:[CXMMCP.V0200_123]FILE1.TLF -
/DIRECTORY_NAME=SYSWORK1 /FILE_NAME=FILE1 /CLASSIFICATION=U -
/READ /FILTYPE=1 /FILESIZE=1657 /RECTYPE=N /RECSIZE=512 /RECCOUNT=1657
DISK$MMCP3:[CXMMCP.V0100_123]FILE2.TLF -
/DIRECTORY_NAME=SYSWORK2 /FILE_NAME=FILE2 /CLASSIFICATION=U -
/READ /FILTYPE=1 /FILESIZE=1657 /RECTYPE=N /RECSIZE=512 /RECCOUNT=1657
DISK$MMCP1:[CXMMCP.ABRACADAB]FILE3.TLF -
/DIRECTORY_NAME=SYSWORK3 /FILE_NAME=FILE3 /CLASSIFICATION=U -
/READ /FILTYPE=3 /FILESIZE=29 /RECTYPE=N /RECSIZE=512 /RECCOUNT=29
This file is used by another application and needs to be edited to make it look like this:
FILE1.TLF /DIRECTORY_NAME=SYSWORK1 /FILE_NAME=FILE1 /CLASSIFICATION=U /READ /FILTYPE=1 /FILESIZE=1657 /RECTYPE=N /RECSIZE=512 /RECCOUNT=1657
FILE2.TLF /DIRECTORY_NAME=SYSWORK2 /FILE_NAME=FILE2 /CLASSIFICATION=U /READ /FILTYPE=1 /FILESIZE=1657 /RECTYPE=N /RECSIZE=512 /RECCOUNT=1657
FILE3.TLF /DIRECTORY_NAME=SYSWORK3 /FILE_NAME=FILE3 /CLASSIFICATION=U /READ /FILTYPE=3 /FILESIZE=29 /RECTYPE=N /RECSIZE=512 /RECCOUNT=29
(In case the formatting is jumbled in the ITRC - the original file has three lines/record, each ending with a "-" and linefeed character. The desired file needs to have information deleted from the beginning of each record and should have one line/record with no "-".
The file sometimes has upwards of 100 records. Manual editing with vi is tedious and I've tried to come up with a script to use sed, awk or perl to complete the editing but have had little success. I usually run headlong into a brick wall when replacing the linefeed characters at the end the first and second lines.
Your assistance is greatly appreciated!
Have a grand day, Bob
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-14-2003 04:03 AM
04-14-2003 04:03 AM
Re: Help with script to edit a text file
#!/usr/bin/sh
while read A B C D E
do
case ${A} in
DISK*) FNAM=${A#*\]}
print -n "$FNAM" ;;
/DIR*) print -n "${A} ${B} ${C}" ;;
/READ*) print "${A} ${B} ${C} ${D} ${E}" ;;
esac
done
Regards,
John
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-14-2003 05:06 AM
04-14-2003 05:06 AM
Re: Help with script to edit a text file
You could try this -
sed 'N;/^DISK/ s/^DISK.*\]//;s/\n//;N;s/\n//;'
- ramd.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-14-2003 05:11 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-14-2003 05:53 AM
04-14-2003 05:53 AM
Re: Help with script to edit a text file
please try the attached script, using your infile as par 1.
regards,
John K.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-14-2003 07:15 AM
04-14-2003 07:15 AM
Re: Help with script to edit a text file
perl -n -e 's/^DISK[^\]]*\]//;if (s/ -$//) { print $_ ; } else { print $_,"\n"; }' infile >outfile
Where infile contains the text and outfile will be the result.
HTH
-- Rod Hills
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-15-2003 01:41 AM
04-15-2003 01:41 AM
Re: Help with script to edit a text file
Thank you all for your helpful answers. I used yours first, Ramkumar, because it was the shortest and it worked like a champ! The others looked great as well. After several days of pounding my head against the wall for this one I finally have an answer. As a good friend says "There's a lot of pleasure to be gained by stopping beating one's head against the wall". Again, thank you for your help, it's why we come here.
Have a grand day, Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-15-2003 07:29 AM
04-15-2003 07:29 AM
Re: Help with script to edit a text file
sed '/-[ ]*$/N;N;s/-[ ]*\n//g'
It seems to work fine and gets rid of the "- " as well.
Regards,
Seth
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-15-2003 07:35 AM
04-15-2003 07:35 AM
Re: Help with script to edit a text file
A correction. I had copied the input from the ITRC and noticed that your spec said "-" then linefeed. What I posted handles any trailing spaces that might be there.
If there aren't any trailing spaces, then use this:
sed '/-$/N;N;s/-\n//g'
It's even shorter!
Regards,
Seth