- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Unix script
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
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
05-31-2001 07:59 AM
05-31-2001 07:59 AM
i.e., (abcdef.cbl to ABCDEF.cbl)
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-31-2001 08:06 AM
05-31-2001 08:06 AM
Re: Unix script
'tr' will do this. For exampe:
# echo "abc"|tr -s '[:lower:]' '[:upper:]'
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-31-2001 08:07 AM
05-31-2001 08:07 AM
Re: Unix script
with a few move commands too...
tr [a-z] [A-Z]
I try to root something out...
Later,
Bill
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-31-2001 08:11 AM
05-31-2001 08:11 AM
Re: Unix script
I don't have script, but you can use perl to do it. Perl has function called "uc"
For example
#!/usr/local/bin/perl
open(LOWER,"filename");
open(UPPER,"
$line=uc;
print UPPER "$line2";
end
Sachin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-31-2001 08:18 AM
05-31-2001 08:18 AM
Re: Unix script
for f in *
do
typeset -u UCASE=$f
print $f $UCASE
done
The -u option on the typeset command sets the UCASE variable to be upper case. I like this method because I'm too lazy to remember all the options for the 'tr' command.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-31-2001 08:20 AM
05-31-2001 08:20 AM
Re: Unix script
Looking further at what you wrote, if you wanted to keep the file extension part (after the dot) in lower case, you might use 'awk' like this, for example:
# echo "abc.txt"|awk -F. '{X=toupper($1);print X FS $2}'
This sets the field delimiter as a dot character, translates the first field to uppercase, and outputs the translated field, the field separator (the dot) and the second, unaltered field.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-31-2001 08:22 AM
05-31-2001 08:22 AM
Re: Unix script
ll *.cbl|awk '{print $9}'>file
tr [a-z] [A-Z]
paste file file2 >file3
while read i,j
do
mv $i $j
done
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-31-2001 09:06 AM
05-31-2001 09:06 AM
Re: Unix script
#!/usr/bin/sh
#
# Script to convert mixed case names
# to lower case
#
for upper_name in *
do
lower_name=$(echo $upper_name | tr "[:upper:]" "[:lower:]")
mv $upper_name $lower_name 2> /dev/null
done
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-31-2001 01:02 PM
05-31-2001 01:02 PM
Re: Unix script
for file
do
my $file `echo$file | tr "[a-z]" "[A-Z]"`
done
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-31-2001 10:40 PM
05-31-2001 10:40 PM
Re: Unix script
look at man tr:
you'll find -> tr -s '[:upper:]''[:lower:]'
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-01-2001 12:01 AM
06-01-2001 12:01 AM
Re: Unix script
# export LC_COLLATE=fr_FR.iso88591
# echo ABCDEF | tr '[a-z]' '[A-Z]'
Not really the result I would expect... But who cares about non US english people... ;)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-01-2001 12:10 AM
06-01-2001 12:10 AM
Re: Unix script
#!/bin/sh
echo "directory who file reside \c"; read DIR
echo "Waiting...."
cd $DIR
for j in .name of any directory?s if there are.
do
cd $DIR/$j
for i in `ls -1`
do
mv $i `echo $i | tr "[a-z]" "[A-Z]"`
done
done
I think i could help you
Mohamed
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-01-2001 08:41 AM
06-01-2001 08:41 AM
Re: Unix script
I agree that if you don't want to convert the extention then perl or awk are your best bets. Also, if you use tr, you probably do not want the -s option, which squeezes two or more repeating characters to a single character. Thus,
echo "aabbcc" | tr -s "[:lower:]" "[:upper:]"
yields the string "ABC", not "AABBCC".
--Bruce
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-01-2001 09:28 AM
06-01-2001 09:28 AM
Re: Unix script
Ah, yes, good catch. I didn't mean to (s)queeze the multiple occurances to one in this case! I did (do) it frequently for strings involving blank characters and ...well...
Thanks!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-02-2001 04:15 AM
06-02-2001 04:15 AM
SolutionThis will list pick all .cbl from a directory
and turn to upper case.
Currently cp is commented, just incase you
need it, uncomment it.
Hope it helps.
#**Start Script****
for i in *.cbl
do
echo $i
name_no_ext=`echo $i| cut -f1 -d"."|tr [a-z] [A-Z] `
echo "Original : " $i
echo "Upper Case : " $name_no_ext.cbl
#cp $i $name_no_ext.cbl
done
#**End Script****
Thanks and Regards
Deepak