LinuxQuestions.org
Share your knowledge at the LQ Wiki.
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 06-25-2020, 12:31 PM   #1
anon041
LQ Newbie
 
Registered: Jun 2020
Posts: 3

Rep: Reputation: Disabled
What this commands do?


1. sort -n << toto > file.txt 2>&1
2. ls -l | grep jpg | wc -l > nb_jpg.txt 2> e.log
3. sudo grep -r ‘‘log’’ /var/log | cut -d : -f 1 | sort | uniq
thank you guys
 
Old 06-25-2020, 12:33 PM   #2
GPGAgent
Senior Member
 
Registered: Oct 2018
Location: Surrey UK
Distribution: Mint 20 xfce 64bit
Posts: 1,026
Blog Entries: 3

Rep: Reputation: 133Reputation: 133
Quote:
Originally Posted by DanutCo View Post
1. sort -n << toto > file.txt 2>&1
2. ls -l | grep jpg | wc -l > nb_jpg.txt 2> e.log
3. sudo grep -r ‘‘log’’ /var/log | cut -d : -f 1 | sort | uniq
thank you guys
Try them!
 
1 members found this post helpful.
Old 06-25-2020, 12:43 PM   #3
Turbocapitalist
LQ Guru
 
Registered: Apr 2005
Distribution: Linux Mint, Devuan, OpenBSD
Posts: 7,308
Blog Entries: 3

Rep: Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721
For background reading:

1. https://wiki.bash-hackers.org/howto/...ction_tutorial

2. https://ryanstutorials.net/linuxtutorial/piping.php
https://mywiki.wooledge.org/ParsingLs

man ls; man grep; man wc;

3. https://youtu.be/o0purspHg-o
man sudoers; man cut; man sort; man uniq;

4. man man;
 
2 members found this post helpful.
Old 06-25-2020, 01:09 PM   #4
hazel
LQ Guru
 
Registered: Mar 2016
Location: Harrow, UK
Distribution: LFS, AntiX, Slackware
Posts: 7,573
Blog Entries: 19

Rep: Reputation: 4452Reputation: 4452Reputation: 4452Reputation: 4452Reputation: 4452Reputation: 4452Reputation: 4452Reputation: 4452Reputation: 4452Reputation: 4452Reputation: 4452
Please don't ask us to do your homework for you. Not only is this against forum rules, but it would lead your teacher to believe that you understood stuff that you don't in fact understand at all. In which case he/she won't explain it to you.
 
Old 06-25-2020, 01:21 PM   #5
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,842

Rep: Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308
Hi and welcome here!
please read the rules of LQ, especially this part:
Quote:
Do not post homework assignments verbatim. We're happy to assist if you have specific questions or have hit a stumbling point, however. Let us know what you've already tried and what references you have used (including class notes, books, and searches) and we'll do our best to help. Keep in mind that your instructor might also be an LQ member.
Which part is unclear?
 
Old 06-25-2020, 01:32 PM   #6
anon041
LQ Newbie
 
Registered: Jun 2020
Posts: 3

Original Poster
Rep: Reputation: Disabled
Thank you everyone for your quick response. First of all this is not my 'homework, I just start using Linux, I have followed a tutorial and I did not understand this line commands. I'm not sorry just because I asked for some questions. Have I have said this is not a home, I am not in school anymore. I have just trying to learn Linux again because when I had 17 years my father used to use it. Thank you and stay safe.
 
1 members found this post helpful.
Old 06-25-2020, 01:34 PM   #7
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,842

Rep: Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308
ok, so please tell us which tutorial is it and exactly where did you stuck?
 
1 members found this post helpful.
Old 06-25-2020, 01:50 PM   #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
Each of those commands is not a simple beginner's level command.

Or at least how they are used.

ls is fairly simple, but combining it with grep, wc, and using I/O redirection makes it more complex and also extremely specific.

You say you're doing a tutorial, I'd wonder if they break down these complex commands and describe them for you.

In the end I don't feel they'll do any harm, they're just processing outputs.

But to run some of them, I think you'd need things set up in advance so you can benefit from using the commands.

Is there a link to this tutorial?
 
Old 06-25-2020, 02:03 PM   #9
average_user
Member
 
Registered: Dec 2010
Location: Warsaw, Poland
Distribution: Slackware
Posts: 560

Rep: Reputation: 220Reputation: 220Reputation: 220
See https://explainshell.com/explain?cmd...e.txt+2%3E%261
 
3 members found this post helpful.
Old 06-25-2020, 09:25 PM   #10
JJJCR
Senior Member
 
Registered: Apr 2010
Posts: 2,150

Rep: Reputation: 449Reputation: 449Reputation: 449Reputation: 449Reputation: 449
Wink

Quote:
Originally Posted by DanutCo View Post
Thank you everyone for your quick response. First of all this is not my 'homework, I just start using Linux, I have followed a tutorial and I did not understand this line commands. I'm not sorry just because I asked for some questions. Have I have said this is not a home, I am not in school anymore. I have just trying to learn Linux again because when I had 17 years my father used to use it. Thank you and stay safe.
Which one you don't understand all of them?

try this:
man sort --> https://ss64.com/bash/sort.html
man ls --> ls in schools is lazy student = in Linux ls is to list files

for grep check out this YT: https://www.youtube.com/watch?v=ckzN9P9zBhM
or check out this one for grep as well: https://opensourceforu.com/2012/06/b...u-grep-basics/

Good luck and study hard...you will get a hang of it one way or another.

Last edited by JJJCR; 06-25-2020 at 09:27 PM. Reason: edit
 
1 members found this post helpful.
Old 06-26-2020, 05:41 AM   #11
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,491

Rep: Reputation: Disabled
Quote:
Originally Posted by DanutCo View Post
1. sort -n << toto > file.txt 2>&1
2. ls -l | grep jpg | wc -l > nb_jpg.txt 2> e.log
3. sudo grep -r ‘‘log’’ /var/log | cut -d : -f 1 | sort | uniq
thank you guys
Not homework, OK, then you need to do a bit of reading man pages.

Break them down into their constituent parts to understand what they do.

The first is sort -n, see what that does, then << & > are for redirection of input from 'toto' into a file called file.txt.

Do the same with the other 2 lines.
 
1 members found this post helpful.
Old 06-26-2020, 08:47 AM   #12
shruggy
Senior Member
 
Registered: Mar 2020
Posts: 3,670

Rep: Reputation: Disabled
Quote:
Originally Posted by fatmac View Post
then << & > are for redirection of input from 'toto' into a file called file.txt.
Not from toto though. If << toto is not mistyped then this is a here document and toto is the heredoc delimiter. But yes, I think here it's just a typo and should be read < toto instead. Then you're right, of course.
 
Old 06-26-2020, 11:09 AM   #13
GPGAgent
Senior Member
 
Registered: Oct 2018
Location: Surrey UK
Distribution: Mint 20 xfce 64bit
Posts: 1,026
Blog Entries: 3

Rep: Reputation: 133Reputation: 133
Quote:
Originally Posted by DanutCo View Post
Thank you everyone for your quick response. First of all this is not my 'homework, I just start using Linux, I have followed a tutorial and I did not understand this line commands. I'm not sorry just because I asked for some questions. Have I have said this is not a home, I am not in school anymore. I have just trying to learn Linux again because when I had 17 years my father used to use it. Thank you and stay safe.
I don't understand what you mean by "..when I had 17 years .."?

Am I correct in thinking english isn't your native language?

And like others post a link to he tutorial please
 
1 members found this post helpful.
Old 06-26-2020, 12:43 PM   #14
shruggy
Senior Member
 
Registered: Mar 2020
Posts: 3,670

Rep: Reputation: Disabled
@GPGAgent. "When I was 17", probably. The StackOverflow profile says "Student in Computer Science" though.
 
2 members found this post helpful.
Old 06-26-2020, 07:22 PM   #15
crts
Senior Member
 
Registered: Jan 2010
Posts: 2,020

Rep: Reputation: 757Reputation: 757Reputation: 757Reputation: 757Reputation: 757Reputation: 757Reputation: 757
Quote:
Originally Posted by shruggy View Post
@GPGAgent. "When I was 17", probably. The StackOverflow profile says "Student in Computer Science" though.
@OP: So, first you ask us to do your homework, which is against the rules. Then you lie about it, not very convincingly. And on top of it we have to find out that we are just second choice because your question got the boot on SO.

@shruggy: Nice detective work
 
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
Need help for Windows cmd commands into Linux terminal commands. windowsNilo Linux - Software 2 07-02-2008 06:26 PM
Need help for Windows cmd commands into Linux terminal commands. windowsNilo Linux - General 2 07-01-2008 06:53 AM
Suse Linux Commands For These Aix Commands? Vaskar Guha Linux - Software 2 12-19-2005 12:45 AM

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

All times are GMT -5. The time now is 05:38 PM.

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