Im Having 6 .csv files in my folder as aca1.csv, aca2.csv, aca3.csv, team1.csv, team2.csv and team3.csv. each file has 80,90,60,70,80 and 90 rows.. I need a bash script file where it will combine or merge files with its type for ex.. aca1,aca2,aca3 will be aca type. and Count the row values(without creating new merged file becauset i want to count the rows only). Write the Count value and Type of the file into another .csv file.. If anyone knows help me?
How to merge similar type .csv files into one and count the rows (without creating new file)
bash;shell script
Try the below as a bash script which works for files named as <pattern><number>.<extension> like abc1.csv, abc02.csv, abc123.csv.You can optionally provide the input directory (default: .) as the first command line argument and the file extension (default: csv) as the second; of course, you will have to compulsorily specify $1 if you want to specify $2.$ cat ./countlinesbyfilecategory.sh#!/bin/bashptrns=$(for fnm in `find ${1:-.} -regex .*[0-9][0-9]*\.${2:-csv}`; do echo $fnm | sed s/[0-9][0-9]*\.${2:-csv}$// ; done| sort -u)for ptrn in $ptrns; do        echo -n $(basename $ptrn)          find ${1:-.} -regex ${ptrn}[0-9][0-9]*\.${2:-csv} | xargs wc -l | tail -1 | awk '{print $1}'done$