Live data from Hacker News

Useful use of cat(1)

in-ulm.de

1–10 of 46 posts

Re: Useful use of cat(1)

#2
You may also create new empty files by saying `touch filename`. This saves three keystrokes (which includes an annoying `>` symbol, requiring the shift key) as compared to the aforementioned `cat` method!

Re: Useful use of cat(1)

#4
post #2

You may also create new empty files by saying `touch filename`. This saves three keystrokes (which includes an annoying `>` symbol, requiring the shift key) as compared to the aforementioned `cat` method!

Or, at least when running Bash (possibly sh, didn't try), just

   >foo
also works to create file "foo".

Re: Useful use of cat(1)

#6
post #2

You may also create new empty files by saying `touch filename`. This saves three keystrokes (which includes an annoying `>` symbol, requiring the shift key) as compared to the aforementioned `cat` method!

what do you mean? "cat > file" allows you to create simple text file not just empty files. As long as you don't need advanced editing, it is the quickest way to do it (well I think).

Re: Useful use of cat(1)

#8
post #4
post #2

You may also create new empty files by saying `touch filename`. This saves three keystrokes (which includes an annoying `>` symbol, requiring the shift key) as compared to the aforementioned `cat` method!

Or, at least when running Bash (possibly sh, didn't try), just >foo also works to create file "foo".

That does not work, but

  :>foo
(the happy file creation operator) does.

Re: Useful use of cat(1)

#9
post #3

cat > file vs. touch file cat file | cmd vs. cmd So even some of the thing listed are still not the best use case for cat

| cat > file vs. touch file

With 'cat > file' you can actually type in the file's contents (then press ^d to finish). 'touch file' merely creates an empty file. (Not that I think 'cat > file' is much faster than 'vi file')

Re: Useful use of cat(1)

#10
ps has a nasty habit of truncating its output. Piping it into cat is a way around this. E.G.

  $ echo $COLUMNS
  118

  $ ps -fp 14706
  UID        PID  PPID  C STIME TTY          TIME CMD
  root     14706 14705  0 Jan29 pts/3    00:00:00 sudo -p [local sudo] Password:  python /usr/lib/sshuttle/main.py pytho

  $ ps -fp 14706 | cat
  UID        PID  PPID  C STIME TTY          TIME CMD
  root     14706 14705  0 Jan29 pts/3    00:00:00 sudo -p [local sudo] Password:  python /usr/lib/sshuttle/main.py python -v --firewall 12300 0
Post reply on HN