Is there still any reason to learn AWK?

If you quickly learn the basics of awk, you can indeed do amazing things on the command line. But the real reason to learn awk is to have an excuse to read the superb book The AWK Programming Language by Aho, Kernighan, and Weinberger. The AWK Programming Language at archive.org You would think, from the … Read more

How to use sed to replace only the first occurrence in a file?

A sed script that will only replace the first occurrence of “Apple” by “Banana” Example Input: Output: Apple Banana Apple Apple Orange Orange Apple Apple This is the simple script: Editor’s note: works with GNU sed only. sed ‘0,/Apple/{s/Apple/Banana/}’ input_filename The first two parameters 0 and /Apple/ are the range specifier. The s/Apple/Banana/ is what … Read more

How can I extract a predetermined range of lines from a text file on Unix?

sed -n ‘16224,16482p;16483q’ filename > newfile From the sed manual: p – Print out the pattern space (to the standard output). This command is usually only used in conjunction with the -n command-line option. n – If auto-print is not disabled, print the pattern space, then, regardless, replace the pattern space with the next line … Read more

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