计算文件,隐藏文件除外

时间:2018-10-03 06:55:46

标签: linux bash

我正在尝试计算当前文件夹及其子文件夹中的所有文件。

var canvas = document.getElementById("barChart");
var ctx = canvas.getContext('2d');
// We are only changing the chart type, so let's make that a global variable along with the chart object:
var chartType = 'bar';
var myBarChart;

// Global Options:
Chart.defaults.global.defaultFontColor = 'grey';
Chart.defaults.global.defaultFontSize = 16;

var data = {
  labels: [ "2012", "2013", "2014", "2015", "2016", "2017"],
  datasets: [{
    label: "Miljoner ton",
    fill: true,
    lineTension: 0.1,
    backgroundColor: "rgba(0,255,0,0.4)",
    borderColor: "green", // The main line color
    borderCapStyle: 'square',
    pointBorderColor: "white",
    pointBackgroundColor: "green",
    pointBorderWidth: 1,
    pointHoverRadius: 8,
    pointHoverBackgroundColor: "yellow",
    pointHoverBorderColor: "green",
    pointHoverBorderWidth: 2,
    pointRadius: 4,
    pointHitRadius: 10,
    data: [56.38, 59.3, 61.81, 58.83, 52.32, 66.86],
    spanGaps: true,
  }]
};

// Notice the scaleLabel at the same level as Ticks
var options = {
  scales: {
    yAxes: [{
      ticks: {
        beginAtZero: true
      }
    }]
  },
  title: {
    fontSize: 18,
    display: true,
    text: 'Källa: Globallife.org',
    position: 'bottom'
  }
};


function addData() {
    myBarChart.data.labels[7] ="Ekologisk palmolja";
    myBarChart.data.datasets[0].data[7] = 14;
    myBarChart.update();
}

// We add an init function down here after the chart options are declared.

init();

function init() {
  // Chart declaration:
  myBarChart = new Chart(ctx, {
    type: chartType,
    data: data,
    options: options
  });
}

3 个答案:

答案 0 :(得分:1)

您可以使用以下find命令:

find -type f ! -regex ".*/\.[^/]+$"  | wc -l

它将找到当前目录中所有文件名不是以.开头的文件,也就是隐藏文件。

答案 1 :(得分:0)

find . -type f -not -path "./.*" | wc -l

说明:

在当前目录(.)中查找类型为file(f)的所有内容,该文件没有以./../开头的路径find的每个输出项目(表示当前目录),然后将输出提供给wc,这是一个要计数的程序,-l参数告诉wc对行进行计数。

答案 2 :(得分:-1)

只需将wc -l轻轻一点即可:

find . -type f -not -path "*/\.*" | wc -l