- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: exporting variables from awk
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
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
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
тАО03-06-2008 05:00 AM
тАО03-06-2008 05:00 AM
Re: exporting variables from awk
i'm trying it on linux, but it must work on HP-UX at work.
Yes, i have learned to handle arrays in bash. well, i'm learning it right now, trying these stuff
matter is that i have resolved in a simple way:
would it work on HP-UX?
for dir in $directories
do
echo "Searching in $dir" >> $log
find $dir -name "$filemask*" 1> fullnames 2> /dev/null
#cat fullnames
if [ -n `cat fullnames` ]; then
break;
fi;
done
i=0
flag=0
echo
while read fullname
do
echo "Checking for posible duplicated file" >> $log
for (( e=0 ; e <= i ; e++ ))
do
echo "checking file $i : $fullname iteration number: $e" >> $log
if [ "$fullname" = "${fullnames_array[$e]}" ];
then
echo "$fullname number $i equals another, it's Discarded" >> $log
flag=1
else
echo "$fullname ins unique!" >> $log
fi
done
if (( flag == 0 ))
then
fullnames_array[$i]=$fullname
i=$(( i + 1 ))
#echo ${fullnames_array[*]}
#echo "print $fullname"
fi
done
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-07-2008 01:31 AM
тАО03-07-2008 01:31 AM
Re: exporting variables from awk
This works in ksh. You have to replace that funny for loop by a while:
for (( e=0 ; e <= i ; e++ ))
for dir in $directories; do
echo "Searching in $dir" >> $log
find $dir -name "$filemask*" 1> fullnames 2> /dev/null
#cat fullnames
if [ -n "$(< fullnames)" ]; then
break;
fi
done
i=0
flag=0
echo
while read fullname; do
echo "Checking for possible duplicated file" >> $log
(( e = 0 ))
while (( e <= i )); do
echo "checking file $i : $fullname iteration number: $e" >> $log
if [ "$fullname" = "${fullnames_array[$e]}" ]; then
echo "$fullname number $i equals another, it's Discarded" >> $log
flag=1
else
echo "$fullname is unique!" >> $log
fi
(( e += 1 ))
done
if (( flag == 0 )); then
fullnames_array[$i]=$fullname
(( i += 1 ))
#echo ${fullnames_array[*]}
#echo "print $fullname"
fi
done < fullnames
echo "found files: ${fullnames_array[*]}" >> $log
I'm not sure why you want to check for a duplicated file, find won't return those.
And you can always use "sort -u" to get rid of dups.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-09-2008 06:54 PM
тАО03-09-2008 06:54 PM
Re: exporting variables from awk
it looks better with a while, but what looks really better for me is "$(< fullnames)" insteed the horrible `cat $fullnames`.
in a deeper way, what are the differences between both?
you're right, find won't return me duplicated...
but i'll cut string routes before doing comparison
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-09-2008 08:47 PM
тАО03-09-2008 08:47 PM
Re: exporting variables from awk
hth,
Hein.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-09-2008 09:10 PM
тАО03-09-2008 09:10 PM
Re: exporting variables from awk
The only problem with that while is that a continue won't work, it will skip the increment.
>what are the differences between both?
Besides what Hein said, it helps you in a catless style of scripting. You really only need cat(1) in a few cases, multiple inputs, 2 GB limitations or copying a file to stdout/stderr.
- « Previous
-
- 1
- 2
- Next »