LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 04-10-2019, 09:46 PM   #1
ticklingtide
LQ Newbie
 
Registered: Apr 2019
Posts: 1

Rep: Reputation: Disabled
Difference between ls & echo


Hi I am planning to solve the Kernighan and Pike Exercises on the book " The Unix Programming Environment".
I would like to validate my responses if anyone has already solved the exercises.

I would like to understand the basic difference between echo & ls?

Ls / echo /

Ls echo

Ls * Echo *

Ls '*' Echo '*'
 
Old 04-10-2019, 11:09 PM   #2
JJJCR
Senior Member
 
Registered: Apr 2010
Posts: 2,150

Rep: Reputation: 449Reputation: 449Reputation: 449Reputation: 449Reputation: 449
Do you have a virtual machine for Linux?

Install it and see the difference.

Or just burn a live cd and boot from it.

Last edited by JJJCR; 04-10-2019 at 11:10 PM. Reason: edit
 
1 members found this post helpful.
Old 04-10-2019, 11:23 PM   #3
scasey
LQ Veteran
 
Registered: Feb 2013
Location: Tucson, AZ, USA
Distribution: CentOS 7.9.2009
Posts: 5,727

Rep: Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211
See man echo and man ls ...
 
1 members found this post helpful.
Old 04-11-2019, 12:01 AM   #4
d745fba1cb70ab9dc02a80ee
Member
 
Registered: Nov 2017
Location: Earth
Distribution: Arch btw
Posts: 82

Rep: Reputation: 1
echo is a command that will print a string passed to it onto the command line. For example, echo hello prints hello. This is most useful in scripts. ls lists all of the files and folders in the directory you are currently in. The man command that scasey is referring to allows you to look up more detailed documentation for commands, but I honestly don't think that's a great place to start.
 
Old 04-11-2019, 01:00 AM   #5
scasey
LQ Veteran
 
Registered: Feb 2013
Location: Tucson, AZ, USA
Distribution: CentOS 7.9.2009
Posts: 5,727

Rep: Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211Reputation: 2211
Quote:
Originally Posted by d745fba1cb70ab9dc02a80ee View Post
echo is a command that will print a string passed to it onto the command line. For example, echo hello prints hello. This is most useful in scripts. ls lists all of the files and folders in the directory you are currently in. The man command that scasey is referring to allows you to look up more detailed documentation for commands, but I honestly don't think that's a great place to start.
Where would you have newbies start if not with the documention?
Please explain how “read the manual” (RTM) is not good advice. Most here are not going to try to explain a command in a sentence, as you did, as that effort has a likelihood of not being complete or correct.

You did marginally OK with echo, but your “definition” of ls completely missed the boat, IMO.
 
Old 04-11-2019, 09:31 AM   #6
fatmac
LQ Guru
 
Registered: Sep 2011
Location: Upper Hale, Surrey/Hants Border, UK
Distribution: Mainly Devuan, antiX, & Void, with Tiny Core, Fatdog, & BSD thrown in.
Posts: 5,487

Rep: Reputation: Disabled
Very basically, ls shows something, whilst echo produces something.
 
1 members found this post helpful.
Old 04-11-2019, 09:56 AM   #7
d745fba1cb70ab9dc02a80ee
Member
 
Registered: Nov 2017
Location: Earth
Distribution: Arch btw
Posts: 82

Rep: Reputation: 1
scasey, I'm not trying to completely discourage them from reading the manual. I just don't find that to be the best place to start, in my experience. I usually just use a search engine and click the first few results I find. The documentation is good if you are looking for specific details of the command, and I often use it for that. However, in my opinion, it is often not organized in a way to make it an easy place to start with a new command. How about we recommend trying both methods and letting the original poster choose his/her own favorite.
 
1 members found this post helpful.
Old 04-11-2019, 10:33 AM   #8
rtmistler
Moderator
 
Registered: Mar 2011
Location: USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu, Debian
Posts: 9,882
Blog Entries: 13

Rep: Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930
In response to the original question, I feel that web searching, viewing the manual pages for each, as well as trying them out, will be excellent help with determining an answer for their question.

At the very least, they'd get experience with seeing the outputs of those 4 forms of commands, and if they actually used a Linux system, they could easily obtain manual page information on each command.

I feel a lot of people don't like to hear this:

They absolutely do need to learn to read the Linux documentation.

Why? Mainly my background and experience, former and current.

I've searched for things on the web, and you find some answers, you find some opinions, you find a lot. Great. As problems grow in complexity, or difficulty, the simple first echelon of obtaining an answer becomes woefully insufficient.

I learned to view the man pages for C library functions or command line functions, maybe just to learn what they were really there for, what their actual synopsis was. That is an example of a first echelon answer in my humble opinion.

However as I progressed with reading more from the man pages, I learned that there are other references, I learned what .h files are needed for a certain library call, I learned what forms of returns and errno values I could expect for these calls, and I learned more information about the command or library call that I hadn't expected, or could not draw upon from general comments on the web unless I was fortunate enough to stumble across a comment from someone noting an unusual behavior. I also learned whether or not a command or library call had been deprecated and if there were replacement suggestions. I also learned that there were reentrant variations of many library functions. You also see things such as how memcpy() is not to be used for overlapping memory regions, but there is a recommended alternative.

Basically I learned how to "read" man pages and benefit from the total information available in them. I learned how to search very lengthy ones.

All of these techniques I use every day. I visited a few man pages in support of my comments here and just to verify what I said about memcpy(). I have been exposed to that information, but there's so much, that I'd not just write it out without at least checking the validity of it.

These are the types of "talents" which new users need to be steered towards. I feel it is fine to guide them with direct statements, however I also feel it is our responsibility to point out to people "how" they take their next steps and the formats where this information is very inclusively given. From there, I feel they stand a better chance of being someone who can self learn how to diagnose or debug their issues.

Last edited by rtmistler; 04-11-2019 at 10:36 AM.
 
1 members found this post helpful.
Old 04-11-2019, 10:30 PM   #9
JJJCR
Senior Member
 
Registered: Apr 2010
Posts: 2,150

Rep: Reputation: 449Reputation: 449Reputation: 449Reputation: 449Reputation: 449
@rmistler
Quote:
These are the types of "talents" which new users need to be steered towards. I feel it is fine to guide them with direct statements, however I also feel it is our responsibility to point out to people "how" they take their next steps and the formats where this information is very inclusively given. From there, I feel they stand a better chance of being someone who can self learn how to diagnose or debug their issues.
Agree on your statement, most newbies/millennial like instant. Instant noodles, instant coffee and instant learning.

That's why most newbies don't care what's happening on the background, they just want what they want. They don't care how it was done.

Problem is, not everything goes smoothly. When troubleshooting comes on the way, that's it. Point here and there.

Gone is the era that you need to troubleshoot for hours, days or weeks. Now search engine, and forums like this comes in handy.

But still boils down, how an individual steer his/her strategy to get things done.
 
1 members found this post helpful.
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
echo 0:$(echo 8*35*37*47 | bc) | xxd -r && echo $(id -un) Linuxanity LinuxQuestions.org Member Intro 1 08-15-2012 06:30 PM
what is the difference between these commands ls * and echo * izrafel Linux - General 5 06-12-2007 12:49 PM
Phục hồi dữ liệu bị mất???, cứ pollsite General 1 06-27-2005 12:39 PM
Kphone echo (echo echo) scabies Linux - Software 0 10-18-2004 02:59 PM
Gotta love those ٱٱٱٱٱٱٱ&# iLLuSionZ Linux - General 5 11-18-2003 07:14 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 12:47 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration