문제

I need to list all the files in a directory like:

/home/rk/a.root /home/rk/b.root /home/rk/c.root

for that I am using

$ls | gawk 'BEGIN{ORS=" "}{print "/home/rk/"$1}'

But in that directory there are 2000 files and I need to list first 100 in one line then next 100 in next line and so on.

Also, Before each line I need to add a line "hadd result.root"

도움이 되었습니까?

해결책

try this:

find /home/rk -type f |xargs -n100

다른 팁

Use printf instead of print to prevent automatically adding newlines. Then declare a counter variable in the BEGIN{ } section, increment it for every file and if that (counter % 100) == 0 print a newline and/or the per-line requisite.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top