LinuxQuestions.org
Latest LQ Deal: Linux Power User 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 02-27-2013, 05:26 PM   #1
doug skillmore
LQ Newbie
 
Registered: Feb 2013
Posts: 4

Rep: Reputation: Disabled
cat command -s , -n


hi i wont bother anyone again today i promise. as you can tell i am doing homework

what is the difference between -s, -n when using cat command?


thank you again in advance
 
Old 02-27-2013, 05:48 PM   #2
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976
Well, as a general advice you should carefully read the man pages, especially when looking for options and their meaning. For example:
Code:
$ man cat
<scroll>
      -n, --number
              number all output lines

      -s, --squeeze-blank
              suppress repeated empty output lines
<omitted>
At this point some exercise is useful to test our understanding. For example I create a file with 4 lines (leaving two lines in the middle empty) using echo and redirection:
Code:
$ echo first line > file
$ echo >> file
$ echo >> file
$ echo fourth line >> file
Ok. Let's try with cat and its options:
Code:
$ cat file
first line


fourth line
The above is just the content of the file, as expected (a usage of cat - without options - is to print out the content of a file). Let's try our options:
Code:
$ cat -n file
     1  first line
     2
     3
     4  fourth line
$ cat -s file
first line

fourth line
Mirroring your question, what's the difference between -n and -s now?

Last edited by colucix; 02-27-2013 at 05:49 PM.
 
Old 02-27-2013, 05:52 PM   #3
etech3
Senior Member
 
Registered: Jul 2009
Location: Virginia
Distribution: Debian Stable Testing Sid Slackware CentOS
Posts: 1,055
Blog Entries: 2

Rep: Reputation: 45
You did look at the help and man files right?

-n, --number >number all output lines
-s, --squeeze-blank >suppress repeated empty output lines
 
  


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
[SOLVED] Cat command confusion. nnjond Linux - Newbie 6 08-12-2010 10:16 AM
Cat command Option foysol_bgd Linux - Newbie 5 12-11-2008 11:33 AM
CAT Command ouncya Linux - Newbie 11 08-26-2007 12:48 AM
cat command juanb Linux - Newbie 4 08-19-2004 12:14 PM
cat Command Moeses Linux - General 1 06-20-2002 04:27 AM


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