-1

I have a perl script, I am not able to get output of script in an excel or text file format. Can someone please help me figure out that ?

perl -MPOSIX -e '
    opendir D, "." || die "open .: $!\n";
    for (sort grep {!/^.{1,2}\z/} readdir D) {
if (@s = lstat$) {
printf("%-58s %s %s\n", $_,
map {strftime("%d-%m-%y", localtime $)} ($s[9], $s[8]))
} else {warn "$: $!\n"}
 }'
Akki
  • 17
  • 4
  • Hello, if you want any help, could you please format your script in a readable way with line jump for example. Also could please explain what you want to do in excel ? text files are quiet easilly importable in excel without to much work. What is not working. – Kiwy Sep 21 '18 at 08:46
  • Hi, I want output of script to produce on text files, Currently it's displaying result on screen, I want output in text file. – Akki Sep 21 '18 at 08:55
  • please [edit] your question to add any relevant information to your question. and in this case it invole formatting your code to make it understandable. – Kiwy Sep 21 '18 at 08:56
  • your question has been answered here: https://unix.stackexchange.com/q/80707/53092 – Kiwy Sep 21 '18 at 09:04
  • 1
    Akki, "_it's displaying result on screen, I want output in text file_". That's called a redirection (`>`). Asking the author of this script might have been faster. – roaima Sep 21 '18 at 09:58
  • Stéphane Chazelas, Request your help here. – Akki Sep 21 '18 at 10:59
  • Hi Thanks roaima and TNT, I have done the redirection and got desired output in .txt file. @TNT, I wasn't able to execute perl -w because perl command was clashing with another perl command in script. – Akki Sep 21 '18 at 13:08

1 Answers1

2

save the script above in a file call it myscript.pl and run it un terminal as:

perl -w myscript.pl > /output_folder/my_output.txt
  • 1
    Just be careful, as the script appears to read the current directory for input filenames, so saving the output to the current directory *may* be confusing. – Jeff Schaller Sep 21 '18 at 15:05