- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- script substitute with regular expression
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
12-02-2003 07:54 PM
12-02-2003 07:54 PM
I need some help on the following script problem.
How can I change a fraction at the beginning of a line in this way :
'Dec 3 09' should be changed into 'Dec 3 09' .
'Dec 12 09' should stay that way.
The first 3 characters ( month) can be different, also the last two digits (day of the month).
Thanks in advance.
Franky
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-02-2003 07:57 PM
12-02-2003 07:57 PM
Re: script substitute with regular expression
Franky
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-02-2003 08:07 PM
12-02-2003 08:07 PM
Re: script substitute with regular expression
If so, then this will return the fields without the extra space
echo "Dec 02 09"| awk '{printf "%s %s %s", $1,$2,$3}'
Please clarify if you need something else.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-02-2003 08:10 PM
12-02-2003 08:10 PM
Re: script substitute with regular expression
sed 's| *| |g'
This will replace all multiple spaces to a single space.
Or, if the month is at the start of the line, it can be done in a better way:
sed 's|^\([A-Za-z]*\) |\1 |g'
(Mind the double space after the closing bracket!)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-02-2003 08:13 PM
12-02-2003 08:13 PM
Re: script substitute with regular expression
Thanks for your quick reply.
No, that's not want I need. Sorry, for the unclear explanation.
This is what I need. I will mark the space with 'SPACE' to make the example clear.
'DecSPACE3SPACE9' should be replaced with
'DecSPACESPACE3SPACE9'
'DecSPACE10SPACE9' should stay that way.
Franky
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-02-2003 08:15 PM
12-02-2003 08:15 PM
Re: script substitute with regular expression
See my reply to Mark.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-02-2003 08:16 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-02-2003 08:23 PM
12-02-2003 08:23 PM
Re: script substitute with regular expression
That's what I needed.
Regards,
Franky
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-02-2003 08:24 PM
12-02-2003 08:24 PM
Re: script substitute with regular expression
try this, using your infile as $1:
#!/usr/bin/sh
typeset -R2 day
while read month day number
do
echo "$month" "$day" "$number"
done <$1
regards,
John K.