- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- convert script to ksh93 (version 93 )
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
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
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
06-07-2013 05:17 AM
06-07-2013 05:17 AM
hello,
i want to convert a script to ksh93 ( korn shell version 93 ) .
Ksh93: https://h20392.www2.hp.com/portal/swdepot/displayProductInfo.do?productNumber=Ksh93
i want to replace following warning(s) like :
warning: line 1: `...` obsolete, use $(...)
following options i find in scripts, but some option's aren't possible to handle (for me)
like "var6" variante 6 in attachment. also "var4" is not ok.
has anybody an idea ?
here are some options, what can be listed in a script KSH88
1. replace : =`
by : =$(
2. replace : `$
by : )
3. replace : `character
by : $(
4. replace : character`
by : character )
5. replace : ?`
by : ? )
6. replace : "`
by : " )
7. replace : }`
by : } )
here is my "sed" converter :
file="demo.sh"
sed -e "s|=\`|=$\(|g" \
-e "s|\`$|\)|g" \
-e "s|\`\([a-z]\)|\$( \1|g" \
-e "s|\([a-z\?\"\?]\)\`|\1 \)|g" ${file} > ${file}.ksh93
ksh -n ${file}.ksh93
testing : sed of attachment and test syntax of new file with version 93 : ksh -n
kind regards
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-07-2013 02:24 PM
06-07-2013 02:24 PM
Re: convert script to ksh93 (version 93 )
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-08-2013 01:18 AM - edited 06-08-2013 01:18 AM
06-08-2013 01:18 AM - edited 06-08-2013 01:18 AM
Re: convert script to ksh93 (version 93)
>warning: line 1: `...` obsolete, use $(...)
You should have done this as soon as you abandoned the Bourne and scummy C shell decades ago.
I started doing that as soon as I read "archaic" under Command Substitution.
(I typically did it manually.)
sed -e "s|=\`|=$\(|g" \
-e "s|\`$|\)|g" \
-e "s|\`\([a-z]\)|\$( \1|g" \
-e "s|\([a-z\?\"\?]\)\`|\1 \)|g" ${file} > ${file}.ksh93
You can do this a little easier without all that quoting if you put it in single quotes:
sed -e 's|=`|=$(|g' -e 's|`$|)|g' -e 's|`\([a-z]\)|$( \1|g' -e 's|\([a-z?"]\)`|\1 )|g'
(You don't need to quote the "?", nor have two of them.)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-10-2013 01:16 AM
06-10-2013 01:16 AM
Re: convert script to ksh93 (version 93)
hello,
thx to your answers.
@ Steven
sed -e 's/`\([^`]*\)`/$(\1)/g'
this handle 90 % of my script(s).
That won't help if the two "`" characters are on different lines, as in: if [ `echo "var6" |grep "var6" > /dev/null 2> /dev/null; \ echo $?` -eq 0 ]
with the other "sed" options i can handle it ? like :
sed -e 's/`\([^`]*\)`/$(\1)/g' -e 's|\([?]\)`|\1)|g' -e 's| `\([a-z]\)| $(\1|g' -e 's|=`|=$(|g' -e 's|`$|)|g'
@ Dennis
in some scripts are statements ( here it is a example of a "case" statement ) like
var7=` echo "a b c" | \
awk ' { print $1 } '` ;;
so i want to "devaluate" the ' of sed
sed -e 's|\([?']\)`|\1)|g' demo_ksh88.sh
like :
sed -e 's|\([?\']\)`|\1)|g' demo_ksh88.sh
>
but i can't devaluate ' in a class
regards
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-10-2013 08:07 PM - edited 06-10-2013 08:07 PM
06-10-2013 08:07 PM - edited 06-10-2013 08:07 PM
Re: convert script to ksh93 (version 93)
>I want to "devaluate" the ' of sed
(This is called quoting in a shell.)
>sed -e 's|\([?']\)`|\1)|g' demo_ksh88.sh
You can stutter quotes: 'don'\''t' (that's two single quotes, not double quote.
sed -e 's|\([?'\'']\)`|\1)|g' demo_ksh88.sh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-13-2013 08:03 AM
06-13-2013 08:03 AM
Solution@ Dennis : Thank you for your correction, now it works.
@ Dennis , Steven : With your input's i have a final solution :
sed -e 's/`\([^`]*\)`/$(\1)/g' -e 's|\([?'\''"]\)`|\1)|g' -e 's| `\([a-z]\)| $(\1|g' -e 's|=`|=$(|g' -e 's|`$|)|g'
this handle 95 % of ksh 88 script(s). the rest you have to correct manually.
regards