How to check if the file is a binary file and read all the files which are not?

Use utility file, sample usage: $ file /bin/bash /bin/bash: Mach-O universal binary with 2 architectures /bin/bash (for architecture x86_64): Mach-O 64-bit executable x86_64 /bin/bash (for architecture i386): Mach-O executable i386 $ file /etc/passwd /etc/passwd: ASCII English text $ file code.c code.c: ASCII c program text file manual page

Copy/Paste in emacs ansi-term shell

You may want to simply switch between character mode and line mode while using the terminal. C-c C-j will run term-line-mode, which treats the terminal buffer more like a normal text-buffer in which you can move the cursor and yank text. You can switch back to character mode by running term-char-mode with C-c C-k.

How does the #! shebang work?

Recommended reading: The UNIX FAQ: Why do some scripts start with #! … ? The #! magic, details about the shebang/hash-bang mechanism on various Unix flavours Wikipedia: Shebang The unix kernel’s program loader is responsible for doing this. When exec() is called, it asks the kernel to load the program from the file at its … Read more

How to execute shell script from LaTeX?

I would do something like the following (partially motivated by what Roman suggested): make your LaTeX file be \documentclass{article} \begin{document} \input{scriptoutput.tex} \end{document} and generate the file scriptoutput.tex using /usr/local/bin/my-shell-script.sh > scriptoutput.tex You could encode this in a makefile if you want to have it run automatically when necessary. Alternatively, you could use the TeX \write18 … Read more

Time condition loop in shell

The best way to do this is using the $SECONDS variable, which has a count of the time that the script (or shell) has been running for. The below sample shows how to run a while loop for 3 seconds. #! /bin/bash end=$((SECONDS+3)) while [ $SECONDS -lt $end ]; do # Do what you want. … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)