How can I count all the lines of code in a directory recursively?

Try: or (when file names include special characters such as spaces) The SLOCCount tool may help as well. It will give an accurate source lines of code count for whatever hierarchy you point it at, as well as some additional stats. Sorted output: find . -name ‘*.php’ | xargs wc -l | sort -nr

Open and write data to text file using Bash?

The short answer: However, echo doesn’t deal with end of line characters (EOFs) in an ideal way. So, if you’re gonna append more than one line, do it with printf: The >> and > operators are very useful for redirecting output of commands, they work with multiple other bash commands.

What does the line “#!/bin/sh” mean in a UNIX shell script?

It’s called a shebang, and tells the parent shell which interpreter should be used to execute the script. Most scripting languages tend to interpret a line starting with # as comment and will ignore the following !/usr/bin/whatever portion, which might otherwise cause a syntax error in the interpreted language.

What is a list in Bash?

I have searched for a similar question here, but surprisingly could not find any. In GNU bash, there is (a construct? a structure? a data type?) called “arrays“. Arrays are well documented in the bash documentation, so I think that I understand the basics. But suddenly, in the documentation there also comes up the term … Read more

How can I compare numbers in Bash?

In Bash, you should do your check in an arithmetic context: For POSIX shells that don’t support (()), you can use -lt and -gt. You can get a full list of comparison operators with help test or man test.

adb shell su works but adb root does not

By design adb root command works in development builds only (i.e. eng and userdebug which have ro.debuggable=1 by default). So to enable the adb root command on your otherwise rooted device just add the ro.debuggable=1 line to one of the following files: If you want adb shell to start as root by default – then add ro.secure=0 as well. Alternatively you could use modified adbd binary (which does not check for ro.debuggable) From https://android.googlesource.com/platform/system/core/+/master/adb/daemon/main.cpp

How do I split a string on a delimiter in Bash?

You can set the internal field separator (IFS) variable, and then let it parse into an array. When this happens in a command, then the assignment to IFS only takes place to that single command’s environment (to read ). It then parses the input according to the IFS variable value into an array, which we can then iterate over. This example will parse … Read more

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