- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- Re: how to paser this string
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
тАО05-16-2007 08:43 AM
тАО05-16-2007 08:43 AM
Re: how to paser this string
I want to diff two directories, and only display the "Only In" result.
Is there an option in the diff that can do that? so, I dont even have to parse the result.
Mimosa
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-16-2007 09:07 AM
тАО05-16-2007 09:07 AM
Re: how to paser this string
> I want to diff two directories, and only display the "Only In" result
See the manpages for 'dircmp' :
http://docs.hp.com/en/B2355-60105/dircmp.1.html
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-16-2007 09:07 AM
тАО05-16-2007 09:07 AM
Re: how to paser this string
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-16-2007 09:19 AM
тАО05-16-2007 09:19 AM
Re: how to paser this string
Something like this:
---------------------------------------
#!/usr/bin/sh
typeset TDIR=${TMPDIR:-/var/tmp}
typeset PROG=${0##*/}
typeset T1=${TDIR}/X${$}_1.tmp
typeset T2=${TDIR}/X${$}_2.tmp
trap 'eval rm -f ${T1} ${T2}' 0 1 2 15
typeset -i STAT=0
if [[ ${#} -ge 2 ]]
then
typeset D1=${1}
typeset D2=${2}
shift 2
if [[ -d "${D1}" && -d "${D2}" ]]
then
ls D1 | sort > ${T1}
ls D2 | sort > ${T2}
comm -3 ${T1} ${T2}
STAT=${?}
else
echo "${PROG}: ${D1} and/or ${D2} not found and/or not directories." >&2
STAT=254
fi
else
echo "Usage: ${PROG} dir1 dir2" >&2
STAT=255
fi
exit ${STAT}
-----------------------------------------
If I didn't make no typing booboo's; that should work. Use it like "dirdiff.sh dir1 dir2". Files that are unique to dir1 appear in column1 of stdout and files unique to dir2 appear in column2.
Man comm for details. You could easily separate this into 3 output files but that is left for you.
- Tags:
- comm
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-16-2007 09:23 AM
тАО05-16-2007 09:23 AM
Re: how to paser this string
----------------------------------------
#!/usr/bin/sh
typeset TDIR=${TMPDIR:-/var/tmp}
typeset PROG=${0##*/}
typeset T1=${TDIR}/X${$}_1.tmp
typeset T2=${TDIR}/X${$}_2.tmp
trap 'eval rm -f ${T1} ${T2}' 0 1 2 15
typeset -i STAT=0
if [[ ${#} -ge 2 ]]
then
typeset D1=${1}
typeset D2=${2}
shift 2
if [[ -d "${D1}" && -d "${D2}" ]]
then
ls ${D1} | sort > ${T1}
ls ${D2} | sort > ${T2}
comm -3 ${T1} ${T2}
STAT=${?}
else
echo "${PROG}: ${D1} and/or ${D2} not found and/or not directories." >&2
STAT=254
fi
else
echo "Usage: ${PROG} dir1 dir2" >&2
STAT=255
fi
exit ${STAT}
-----------------------------------------
Dircmp may be too intensive for you because it not only does file names but also compares the files themselves.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-16-2007 10:04 AM
тАО05-16-2007 10:04 AM
Re: how to paser this string
I want to learn different ways to parse the strings anyway. I read every post and try to understand it.
you guys are being extremely helpful.
really appreciate.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-16-2007 10:32 AM
тАО05-16-2007 10:32 AM
Re: how to paser this string
# VAR=$(diff /dir1/dir2 /dir1/dir3)
then echo'ing the doubly-quoted VAR will do the trick w/o any scripting...
# echo "$VAR"
~hope it helps
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-16-2007 08:32 PM
тАО05-16-2007 08:32 PM
Re: how to paser this string
why not the old good Unix command diff?
/> ls -1 t1
a
b
/>ls -1 t2
b
c
/> diff t1 t2
Only in t1: a
Only in t2: c
It shows only the file that are not in both dirs.
HTH,
Art
- « Previous
-
- 1
- 2
- Next »