command: cat



captain-sensible

Well-Known Member
Credits
14,907
apparently Richard Stallman was one of the major contributors to cat ; you can use it to open a file and output it to something else.I used it in a slackbuild like so:
cat $CWD/slack-desc > $PKG/install/slack-desc
 

JasKinasis

Well-Known Member
Credits
7,705
cat command examples:

show the contents of /etc/passwd while searching for the user 'rob'
Code:
[[email protected] ~]# cat /etc/passwd|grep rob
rob:x:500:500::/home/rob:/bin/bash
As this has been necro-posted and raised from the dead, I'll take this opportunity to point out that there is never a need to use cat file | grep pattern.

You can simply use grep or ag instead:
Code:
grep rob /etc/passwd
OR
Code:
ag rob /etc/passwd
ag (aka the silver searcher) - is basically a multithreaded grep on steroids - great for quickly searching through large files, or through code-bases where you have a lot of files!

Just sayin'! ;):p:D
 

Rob

Administrator
Staff member
Credits
469
wow, old post lol..

Even though I know i don't need to use 'cat file | grep something', i still do it every day from muscle memory haha.. could be i'm catting something, then just uparrow and add the grep to the end most of the time though.
 

Rob

Administrator
Staff member
Credits
469
Hey there @daysaputra - welcome to the forum. You're in the right place.. there are some tutorials here and plenty of other articles and things to read. I wrote a little ebook (in my signature) that might help, but mainly try to use Linux as much as you can and things will start seeping in.
 

captain-sensible

Well-Known Member
Credits
14,907
hey @daysaputra this ism y philosophy- you can read as much fishing books as you like; you then have "head knowledge" . the way to get actual knowledge is just to do some actual fishing. Thus google for some linux command lines and just try them. One question do you have the means of trying linux command line ? Do you have access to any linux OS or Windows Subset for Linux (Windows 10). if not thats your first objective.

After that its just a case of opening a terminal window and stating with basics.

$ uname -r
$uname -m
$ pwd
$whoami

$ cd Desktop
$ ls --color

$ cd ~

$ cd Desktop

$ touch play.txt

$ nano play.txt






!
then your on your way :^)
 
Last edited:
  • Like
Reactions: Rob

dos2unix

Well-Known Member
Credits
4,576
The cat command will allow you to see an entire file in your terminal quickly. This is more useful for smaller files unless you're grepping for certain things.
It seems this is mostly for text files, but the "strings" command, will often find text in a binary file.

example: strings vlc

But grep will find strings in binary files also.
 
$100 Digital Ocean Credit
Get a free VM to test out Linux!


Latest posts

Top