- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- diff command without show differences ...
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
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
тАО01-03-2006 05:14 AM
тАО01-03-2006 05:14 AM
i'm making a script where i'm working with diff sentece, how can i make to not show diferences if there are?
i tryed to send with 2/dev/null but is not working?
NOW and LAST are files:
$ diff NOW LAST 2>/dev/null
1c1
< UUvxfsd root
---
> vxfsd root
Is different
i'd like appears how it looks like next withow diferences ...
$ diff NOW LAST 2>/dev/null
is different
how can i do it ?
Manuales.
Solved! Go to Solution.
- Tags:
- diff
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-03-2006 05:19 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-03-2006 05:24 AM
тАО01-03-2006 05:24 AM
Re: diff command without show differences ...
i tryied with 1>/dev/null instead of 2/dev/null and worked !!!
:D :D :D :D :D
thanks !!!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-03-2006 05:34 AM
тАО01-03-2006 05:34 AM
Re: diff command without show differences ...
Example-
if cmp -s NOW LAST ; then
echo files are same
else
echo files are different
fi
HTH
Rod Hills
- Tags:
- cmp
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-03-2006 05:42 AM
тАО01-03-2006 05:42 AM
Re: diff command without show differences ...
We could amend things thusly, too:
# diff NOW LAST > /dev/null && echo "are same" || echo "are different"
# cmp -s > /dev/null && echo "are same" || echo "are different"
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-03-2006 06:01 AM
тАО01-03-2006 06:01 AM
Re: diff command without show differences ...
i know that diff with if only work with files :
"if diff NOW LAST
then ..."
but, how can i compare strings instead of files?
this is because in my script i'm redirecting string to a file, and for to make more short my script, how can i compare strings??
tempo2 file contains: process (ps -fea and user process, check only there are two fields separated by an space) tempo2 file was generated from a function and is a file:
.......................
.......................
.......................
/etc/opt/resmon/lbin/p_client root
/etc/opt/resmon/lbin/registrar root
/opt/dce/sbin/rpcd root
/opt/egb/lbin/egcd root
/opt/hpnp/bin/hpnpd root
/opt/itadm/it_sw/bin/itappssv -si00 -snsiddp -dbITP -t1 itadm
......
.......
.......
next function of script is a function wich verify how much processes are running with same name and then put the name of the user:
NOW=ACTUAL (ACTUAL in spanish is like now in english)
LAST=ULTIMO (ULTIMO in spanish is like last in english)
function obtiene_total
{
typeset -i x=0 totalproc=0
while read actual
do
if [ "$x" = 0 ]
then
echo $actual > ULTIMO
else
ultimo=`tail -1 ULTIMO`
echo $actual > ACTUAL
if diff ULTIMO ACTUAL 1>/dev/null
then
let " totalproc = $totalproc + 1 "
band=igual
else
case $band in
igual) echo $totalproc $ultimo >> procesos.txt
band=salta ;;
esac
typeset -i totalproc=0
case $band in
diferents) let " totalproc = $totalproc + 1 "
echo $totalproc $ultimo >> procesos.txt ;;
esac
band=diferents
fi
fi
echo $actual > ULTIMO
let " x = x + 1 "
done < tempo2
rm ACTUAL ULTIMO
}
The result will be:
..........
..........
16 /usr/sbin/biod 16 root
1 /usr/sbin/biod 16 root
1 /usr/sbin/cron root
1 /usr/sbin/envd root
1 /usr/sbin/getty console console root
1 /usr/sbin/guardAgntd root
1 /usr/sbin/hp_unixagt root
1 /usr/sbin/inetd root
1 /usr/sbin/lpsched lp
1 /usr/sbin/mib2agt root
1 /usr/sbin/netfmt -C -F -f /var/adm/nettl.LOG00 -c /var/adm/c root
20 /usr/sbin/nfsd 20 root
1 /usr/sbin/nfsd 20 root
1 /usr/sbin/ptydaemon root
1 /usr/sbin/pwgrd root
...................
...................
...................
...................
first field is number of same process and second field is the name of the process.
well question is:
how can i compare strings with diff and cpm?
Thanks !!!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-03-2006 06:11 AM
тАО01-03-2006 06:11 AM
Re: diff command without show differences ...
Since you are dealing with ASCII data, redirect your output to a file and, again, use 'diff' but this time add some other options to ignore trailing blanks ('-b'); ignore whitespace and tabs during equality checking ('-w'); and ignore upper/lowercase differences ('-i'):
# diff -bwi file1 file2
By the way, I should have written:
# cmp -s NOW LAST && echo "are same" || echo "are different"
...in my last post. The '-s' of 'cmp' as Rodney used is designed for "silence" --- no output; hence no need to redirect anything to '/dev/null'/
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-03-2006 06:44 AM
тАО01-03-2006 06:44 AM
Re: diff command without show differences ...
Does this give the desired result:
UNIX95= ps -A -oargs= -ouser= | sort | uniq -c | pg