Hello! I'm just learning the shell, and I would really like to know how to do this:
Given these 2 commands:
ls -l
ls -le
How can I, with a one-liner, ask the shell to show me visually in the shell, what the difference is between the output of the two commands? They look the same to me and I would like the shell to report the difference, if any.
I hope that makes sense. I think this is probably something basic but seems to be a very powerful procedure for future use in comparing other outputs. I don't think I need python for this, which I don't know at all, but it seems like this is a pipe-able procedure within the shell...?
Thanks Scrutinizer! Can you help me understand the output a little better?
[verdepollo, thanks for the assistance, but I meant have the shell report the differences in the outputs of 2 commands, not what does ls -l do or ls -le do].
What Operating System are you running?
What Shell are you using?
Scrutinizer has quite correctly posted code using the unix "diff" program which is common to all unix versions.
The "diff" program is a buffered context compare program and shows the context of the difference and the address within each file of the difference. It is a very useful tool for comparing files which are similar and where the data is in no particular order. The "<" ">" signs tell you which file the difference came from.
It is very useful for comparing program code. For larger files there are usually special versions of diff supplied like "bdiff".
Let's say we just want to know the differences regardless of which file they came from and with no context and in no order relative to either file. I use this technique a lot for comparing code, but it works equally well for "ls".
(Yes I know I have used "cat". I like left-to-right flow).
If you really need a one-line solution just replace each newline with a semi-colon.
(This is just hobby/personal use. I'm on a mac (10.6.6). I have been strictly Windows since 3.1 and I'm trying to get more familiar with what my mac is able to do. I know i'm able to open the terminal app and interface using unix commands, but I don't really know unix at all. I know there's tons of apps for macs to do simple things but are just wasting space and processing so I figured, I might as well learn the OS because that should cover about 90% of those apps. I don't prefer wasting system resources either, so I want to get optimal use out of my system. I really dig apps that use the system properly, and cleverly, rather than rewriting functions to do what's already available thru calling system commands.)
methyl: thanks for the reply. I was playing around with shell scripting trying to figure it out. I was under the impression that I could call unix commands like I would call functions in a oop language, then pipe commands together to get like a variable out of the output, then feed that into some other unix command. Am I looking at this the wrong way?
i.e. in the shell:
command (feed result to) search_for_result_from_previous_command (feed result to) echo_to_standard_output
You can do this sort of thing with unix, right? Because I can imagine endless possibilities with a system like this.
Hi all I want to make sure I was understanding this correctly
if a cron job command was
* */20 * * * command
does that mean this command will run every 20 hours?
also what is the difference between the following two?
0,20,40 * * * * command
20 * * * * command
I believe the first... (3 Replies)
Hi all,
I'm new in this forum.
I'm looking for the difference between the HACMP commands with the prefix "cl" and "cli".
The first type are under /usr/es/sbin/cluster/sbin directory and the second are under /usr/es/sbin/cluster/cspoc directory.
I know that the first are called HACMP for AIX... (0 Replies)
Looking at the performance hit on my server, does it matter wich command I run?
client # rsh server tar –cf - . | tar –cv –f –
or
server # tar –cf – . | rsh client ‘cd target && tar –xv -f –‘
I think it doesn't really matter because both command strings involve a tar being run on... (4 Replies)
Hi,
I need to know the difference between this commands:
grep * *search*
grep "*" *search*
As far as i know does the 2nd command search for files which have a name with *search* and greps then all which have chars from a-z in the file content.
But was does the first command??
Best... (1 Reply)
HI all,
Please clarify the difference between the following
pm2srv:/var/opt/temip/vf/scripts/saiki#awk '{RS = ":"} ; {print $0}' testf2
hey:wasup:howru:
Yes
I
am
fine
pm2srv:/var/opt/temip/vf/scripts/saiki#awk 'BEGIN { RS = ":" } ; { print $0 }' testf2
hey
wasup
howru
Yes
I... (0 Replies)
Hello All, I have a question about the difference between two commands. I am using Korn and was told by the Unix admin that 'nohup <command> &'
equals 'nohup ./<command> &. That there is no difference betwewen the two. Is this true? Also, does the command './<command> &' provide a disconnect... (4 Replies)
Hi,
I would like to know what is the difference between executing the mount command in the following ways...
eg:
/usr/sbin/mount -F <something>
AND
mount -F <something>
I mean , just executing the mount command as opposed to specifying the path and then executing it?
... (3 Replies)