Tag Info

New answers tagged

2

Each part gets the integer divide ($((a/b))). If the line number modulo the number of parts ($((a%b))) is not zero then you have to distribute the spare modulo number over the parts. One solution is to give the modulo value number of parts an additional line. SPLIT_NUM_THREADS=15 TOTAL_LINES=52 for((i=0;i<$((TOTAL_LINES%SPLIT_NUM_THREADS));i++)); do ...


3

You're using the wrong tool. wc will count lines of input but since you're using sed -i, there are no lines printed so nothing for wc to count. Even without it, the sed command would have printed all lines of the file so it still would not have worked correctly. Here's a different approach: Use perl instead find . -name \*.php \ -exec perl -i -lpe ...


0

I used xargs with find : find . -type f | xargs -i sh -c 'echo -n `date -r {}`; \ echo -n " "; echo -n `wc -l {}`; echo ' Output: Thu Oct 30 19:16:38 IST 2014 0 ./b Thu Oct 30 19:16:38 IST 2014 0 ./a Thu Oct 30 19:16:38 IST 2014 0 ./c Thu Oct 30 19:16:56 IST 2014 10 ./testfile Little formatting with printf instead of echo as done ...


2

The find-based solutions look the most elegant, but just for fun here are a couple of other ways to attack this. This one uses sed & head to clean up the output of wc, then uses join to combine that to the output of stat, using the file name as the join field. pat="A*";join -1 2 -2 1 -t ' ' <(wc -l $pat|head -n-1|sed 's/^[ ]*//') <(stat -c '%n ...


0

I used awk as shown below: wc -l * | head --lines=-1 | while read num file do echo -n $num" " ls -l $file | awk '{ for (i=6; i <= NF; i++) printf $i " " }' echo done head is used to remove the last line (total line of wc output). num contains the number of line of file. awk is used to print the time output from ls -l output.


6

Here is something with find + wc + date. find . -maxdepth 1 -exec sh -c '[ -f "$0" ] && \ printf "%6s\t\t%s\t%s\n" "$(wc -l<"$0")" "$(date -r "$0")" "$0"' {} \; Instead of date -r one can also use for example stat -c%y. The output looks like this: 394 Thu Oct 16 22:38:14 UTC 2014 ./.zshrc 7 Thu Oct 30 11:19:01 UTC 2014 ...


-2

What about : ls -lrth yourfile|awk '{print $6 $7 " " $8 system("wc -l " $9) }' > /tmp/temp.txt tr '\n' ' ' < /tmp/temp.txt



Top 50 recent answers are included