LinuxQuestions.org
Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
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-18-2004, 09:59 PM   #1
Dandy
LQ Newbie
 
Registered: Apr 2004
Posts: 1

Rep: Reputation: 0
Question Having problems figuring out these commands


1. Can you please give me an example of a command that would display a text file named myfile.txt and sort it on the same command line using the pipe command to join the two parts together.

(This is a Scenerio)
2. I have a log file named logins.txt that monitors logins to my system. It contains multiple lines with duplicate user names. What command could I use so that I could display the file showing only one instance of every login?

3. If I have a script named, myscript.sh, what is the syntax for running it at the command prompt?

4. What command would I use to give me the last 20 lines of a file called inventory.txt?
 
Old 04-18-2004, 10:17 PM   #2
MiscGeek
Member
 
Registered: Jan 2003
Location: Georgia, US
Distribution: RHEL WS4
Posts: 189

Rep: Reputation: 30
Re: Having problems figuring out these commands

Quote:
Originally posted by Dandy

3. If I have a script named, myscript.sh, what is the syntax for running it at the command prompt?
If you have the correct header for the file ( #!/bin/sh ), and it's executable, chmod +x myscrip.sh, you can simply type the file name to run it. Note: if you're in the same directory you have to type ./myscript.sh.

Another option is to call like so /bin/sh myscript.sh
Quote:

4. What command would I use to give me the last 20 lines of a file called inventory.txt?
tail -n20 inventory.txt
 
Old 04-18-2004, 10:21 PM   #3
bigrigdriver
LQ Addict
 
Registered: Jul 2002
Location: East Centra Illinois, USA
Distribution: Debian stable
Posts: 5,891

Rep: Reputation: 351Reputation: 351Reputation: 351Reputation: 351
1. cat myfile.txt | sort --dictionary-order
2. cat logins.txt | sort --unique
3. If you CD to the directory which contains myscript.sh, then ./myscript.sh will execute the script, assuming execute permissions are set. The ./ tells Bash that the script is located in the current working directory. Otherwise, from anywhere, /path/to/myscript.sh will work also work.
4. tail -n 20 inventory.txt
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
gpg: figuring who something was encrypted for prell Linux - Software 0 01-05-2005 09:15 AM
Help figuring out ESR Problem sboney Linux - Newbie 1 07-28-2004 04:53 PM
Finally figuring this out... (slack 9.1) johnp General 6 05-17-2004 09:17 PM
Figuring out download speed chrisk5527 Linux - General 2 01-28-2004 07:35 AM
figuring out what ports are open joesbox Linux - Security 7 03-18-2003 04:44 PM

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

All times are GMT -5. The time now is 04:03 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration