Using PV to Count lines and show total lines rather then total bytes in the pipe
Tag : linux , By : kameel
Date : March 29 2020, 07:55 AM
I hope this helps you . du comes with the -s flag to only display the total, so just do e.g. this instead: $ du -sh /tmp | cut -f1
4.9M
$ find /tmp/ | pv >/dev/null
44.6kiB 0:00:00 [3.19MiB/s] [ <=>
^^^^^^^
$ find /tmp/ | pv -l >/dev/null
1.24k 0:00:00 [86.5k/s] [ <=>
^^^^^
$ find /tmp/ | wc -l
1237
^^^^
|
diff line-format: Show delete, new, and changed lines?
Tag : linux , By : Ravenal
Date : March 29 2020, 07:55 AM
seems to work fine The LTYPEs offered by both BSD and GNU diff are "old", "new", and "unchanged". You thus can't distinguish between "new" and "changed". That said, to get some distinctions in your format strings, you need to fill them out correctly. In %dn, both the d and the n are consumed (the former specifying a decimal value, the n specifying that it refer to the line number, or the number of lines modified, depending on context). Thus, if you want any extra characters (such as a c, d or a), you need to add those characters after that substitution has complete. # declaring functions to allow testing without creating files on-disk
backup () { printf '%s\n' user1:password:17002:0:99:7::: user2:password:17002:0:99:7::: user3:password:17002:0:99:7:::; }
main () { printf '%s\n' username1:password:17002:0:99:7::: user3:password:17004:0:99:7::: newUser:password:17005:0:99:7:::; }
diff \
--unchanged-line-format=":%dnu: %L" \
--old-line-format=":%dnd: %L" \
--new-line-format=":%dnn: %L" \
<(backup) <(main)
|
How to insert total number of lines in a new line before the first line command?
Date : March 29 2020, 07:55 AM
I hope this helps . I have thousands of .xyz files which are chemical coordinates like this one (for instance): , You can do it as a composite command: (wc -l < fileA && cat fileA) > outputA
mkdir output
ls *.xyz | while read filename; do
(wc -l < $filename && cat $filename) > output/$filename
done
tee xxx < fileA | wc -l > xxx # don't do this
|
read and print a file line by line along with the line number and the total number of lines in each line in bash
Date : March 29 2020, 07:55 AM
I wish did fix the issue. I want to write a bash that it reads a file line by line as a variable and in the output it prints the total number of lines, the number of each line, and the value of each line. for example: file.txt :
|
Show number of changed lines per author in git
Date : March 29 2020, 07:55 AM
|