Tag Info

Hot answers tagged

36

asciio I've used asciio for several years. Many of the diagrams on this site I've created using asciio. example vncviewer .-,( ),-. __ _ .-( )-. gateway vncserver [__]|=| ---->( internet )-------> __________ ------> ____ __ /::/|_| '-( ).-' [_...__...°] ...


32

Indeed there is. It is called wc, originally for word count, I believe, but it can do lines, words, characters, bytes, and the longest line length. The -l option tells it to count lines. wc -l mytextfile


28

UNIX/Linux does not have the same early DOS / CP/M heritage that Windows does. So extensions are generally less significant to most UNIX utilities and tools. I usually use a command-line only environment. Extensions in such an environment under Linux aren't really significant except as a convenience to the operator or user. (I don't have enough ...


21

There is already a command for this: seq 100 104 will print these numbers on separate lines: 100 101 102 103 104 So just direct this output into a file: seq 100 104 > my_file.txt and seq 100 2 104 will print in increments of two, namely: 100, 102, 104


19

Unlike Windows, in UNIX systems the filetype is not determined by the extension. The file extension is and was simply a visual indicator for humans. You can name a JPEG foo.c and open it in Gimp. Another contrast from Windows is that on UNIX systems you must use the entire filename, while Windows will often take care of it for you (e.g., running just ...


14

The problem, of course, is that you run grep on the big file 10,000 times. You should read both files only once. If you want to stay outside scripting languages, you can do it this way: Extract all numbers from file 1 and sort them Extract all numbers from file 2 and sort them Run comm on the sorted lists to get what's only on the second list Something ...


14

It should be pointed out that Mac OS X uses \n a.k.a linefeed (0x0A) now, just like all other *nix systems. Only Mac OS versions 9 and older used \r (CR). Reference: Wikipedia on newlines.


13

You have a lot of options! pdftotext from poppler has already been mentioned. There's a Haskell program called pdf2line which works well. calibre's ebook-convert commandline program (or calibre itself) is another option; it can convert PDF to plain text, or other ebook-format (RTF, ePub), in my opinion it generates better results than pdftotext, although ...


13

There is a difficult way and a much easier way. The difficult way is to use natural language parsing to give a probability that a given line is in English and discard such lines. The easier way is to take a list of English stop words and delete lines that contain elements from that list. If you wanted to decrease the chance of mis-categorizing a line, you ...


12

Have a look at artist-mode or picture-mode for Emacs (see also this screencast). You might also want to check out ditaa.


12

It is known as carriage return. If you're using vim you can enter insert mode and type CTRL-v CTRL-m. That ^M is the keyboard equivalent to \r. Inserting 0x0D in a hex editor will do the task. How to remove? You can remove it using the command perl -p -i -e "s/\r//g" filename. As the OP suggested in the comments of this answer here, you can even try a ...


12

Switching the color is done through escape sequences embedded in the text. Invariably, programs issue ANSI escape sequences, because that's what virtually all terminals support nowadays. The escape sequence to switch the foreground color to red is \e[31m, where \e designates an escape character (octal 033, hexadecimal 1b, also known as ESC, ^[ and various ...


9

GNU grep has the following options: grep --only-matching --ignore-case --fixed-strings --file /usr/share/dict/british-english-insane /path/to/file.txt This outputs strings found one-per-line. Here /usr/share/dict/british-english-insane is a wordlist provided by the Debian package wbritish-insane.


9

tr can do that: tr -d \" < infile > outfile You could also use sed: sed 's/"//g' < infile > outfile


9

paste should be able to do the job. Here x.1 is the name of the file paste <(grep -E '^[[:alpha:]]+$' x.1) \ <(grep -E '^[[:digit:]]+$' x.1) \ <(grep -E '^[[:digit:]]+[.][[:digit:]]+$' x.1)


8

This answer is based on the awk answer posted by potong.. It is twice as fast as the comm method (on my system), for the same 6 million lines in main-file and 10 thousand keys... (now updated to use FNR,NR) Although awk is faster than your current system, and will give you and your computer(s) some breathing space, be aware that when data processing ...


8

Yes, definitely do use a database. They're made exactly for tasks like this.


8

There is tool source-highlight. Alias example: alias ccat="source-highlight --out-format=esc -o STDOUT -i"


8

With bash, zsh, GNU echo or some implementations of ksh on some systems, this can be decoded simply by echo -e after replacing all % with \x. url_encoded_string="%D1%80%D0%B5%D1%81%D1%83%D1%80%D1%81%D1%8B" temp_string=${url_encoded_string//%/\\x} printf '%s\n' "$temp_string" # output: \xD1\x80\xD0\xB5\xD1\x81\xD1\x83\xD1\x80\xD1\x81\xD1\x8B echo -e ...


7

Yes, there is. Though its name is djvutxt, not djvu2text. It is part of: the djvu package on Gentoo. the djvulibre-bin package on Debian/Ubuntu.


7

Linux ships with the seq command which does exactly that. If you don't have the seq command, it's an easy one-liner: i=100; while [ $i -le 104 ]; do echo $i; i=$((i+1)); done >b.txt or in ksh/bash/zsh for ((i=100; i<=104; i++)); do echo $i; done >b.txt or in zsh print -l {100..104} >b.txt


7

There is no end-of-file character in Unix or Linux filesystems. The read() system call returns 0 on end-of-file condition, if the file descriptor in use refers to a regular file. read() works differently on sockets and pipes. You don't get a special character to mark end of file. wc gave you 30 as a character or byte count because the first line has 12 ...


7

On Debian and derivatives (including Ubuntu), this is easy with a simple call to rename: $ touch 'A B' $ rename 'tr/ A-Z/-a-z/' -- * $ ls a-b But your rename is a different utility with the same name.


7

In vim you can do something like: :set showbreak=..


7

Use recode, e.g.: recode /cr file Note: the fact that you can see the contents in the terminal with cat file is that the Mac end-of-line is CR, which puts the cursor at the beginning of the line without going to the next line, so that everything gets overwritten.


6

Another option would be to use grep to find the number of times a pattern is matched: grep --regexp="$" --count /path/to/myfile.txt In this example, $ is an expression that evaluates to a new line (enter button is pressed) --count suppresses normal output of matches, and displays the number of times it was matched. The /path/to/myfile.txt is pretty ...


6

input $ cat input.txt Id sno1 lc1 sno2 lc2 sno3 lc3 sno4 lc4 RM1 98 ss1 88 ms1 78 gs1 45 rs1 RM2 23 ss2 44 ms2 98 gs2 15 rs2 RM3 45 ss3 100 ms3 33 gs3 10 rs3 RM4 45 ss4 45 ms4 12 gs4 11 rs4 awk script $ cat row_max.awk NR == 1 { for (i = 1; i <= NF; i++) headers[i] = $i; ...


6

You may want to read an Intro to Unix File System.


6

In general I've found keeping a strict, descriptive, naming convention to be very helpful. You don't need the extension in Unix, but I'd keep it for two reasons: 1) If that file will ever be read by a windows machine, it'll be easier to open than trying to find "open with...". 2) Extensions helps you, the user, figure out what the file is doing. In our ...



Only top voted, non community-wiki answers of a minimum length are eligible