LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
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 02-27-2013, 04: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, 04:48 PM   #2
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983
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 04:49 PM.
 
Old 02-27-2013, 04: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



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 09:16 AM
Cat command Option foysol_bgd Linux - Newbie 5 12-11-2008 10:33 AM
CAT Command ouncya Linux - Newbie 11 08-25-2007 11:48 PM
cat command juanb Linux - Newbie 4 08-19-2004 11:14 AM
cat Command Moeses Linux - General 1 06-20-2002 03:27 AM

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

All times are GMT -5. The time now is 10:20 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