- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- comparing files using 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
Forums
Discussions
Discussions
Forums
Discussions
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
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-04-2001 07:16 AM
12-04-2001 07:16 AM
comparing files using awk
I'm not a script guy and I'm currently in a situation which is, I need someone who could help me create a simple (for the experts) awk script that will compare system files against users input.
ex. - users entered "SAMPLE.TXT" (usually
upper case)
- systems could have "Sample.txt"
or "sample.txt"
or "sample.TXT"
regardless whatever the system has. Script should match users input against files in the system and proceed it's process. BTW, this is to ftp a file from one machine to another.
Your reply would be greatly appreciated.
Thanks
Joey
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-04-2001 07:25 AM
12-04-2001 07:25 AM
Re: comparing files using awk
This will ignore case and pick up files.
For ex.,
DIR=/some_path
echo "Enter your file name:"
read file
ll $DIR |grep -i $file
if [ $? = 0 ]
then
echo $file is there
else
echo $file doesnot exist
fi
It will become little bit complicated if you use the path names.
-Sri
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-04-2001 07:26 AM
12-04-2001 07:26 AM
Re: comparing files using awk
This will find any way the word sample was spelled in the filename searched.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-04-2001 07:28 AM
12-04-2001 07:28 AM
Re: comparing files using awk
Tony
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-04-2001 07:30 AM
12-04-2001 07:30 AM
Re: comparing files using awk
This may not be what you want, and it doesn't use awk, but it'll find all files under a directory, regardless of case, that match the user's input:
================================
#!/bin/ksh
DIR=search-directory
echo Enter filename: '\c'
read FILENAME
find $DIR -type f | grep -i "/${FILENAME}$"
==================================
Obviously, you need to edit the "DIR=" line.
Rgds, Robin. (duplicate of reply in 1st post!)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-04-2001 07:39 AM
12-04-2001 07:39 AM
Re: comparing files using awk
This script might help:
echo | ls -l | grep -i $1
If this script is named finder, then typing:
finder
should work for the current directory.
HTH,
Vince
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-04-2001 08:23 AM
12-04-2001 08:23 AM
Re: comparing files using awk
#!/usr/bin/sh
if [ "$#" -ne 2 ]
then
echo "USAGE=script_name DIR_NAME FILE_NAME"
exit 1
fi
DIRNAME=$1
FILENAME=$2
for i in `find $DIRNAME -depth`
do
TEST=`echo $i | grep -v -i $FILENAME`
if [ "$TEST" -eq "" ]
then
echo $i
fi
done
Hope this will help,
Gideon