I need the same output in FMTIME as in the following command:

FMTIME=`ls -l --time-style=+%s $FILE | cut -f6 -d' '`

but my Linux (running busybox) does not support ls --time-style. I am running ::

Linux SAM 3.10.35 #5644 SMP Wed Oct 28 12:37:28 CST 2015 x86_64 GNU/Linux synology_cedarview_412+

I have stat available and awk and cut .

  • can you provide output of stat /etc/hosts (by editing the question) ? as well as OS, so we can edit tags for this question. – Archemar Nov 29 '15 at 14:23
  • What is the output of stat --help ? That will tell us the version. – Mark Plotnick Nov 29 '15 at 14:34
  • @Archemar I don't think /etc/hosts is relevant. – Mikel Nov 29 '15 at 15:50
  • @Mikel I was just expecting a sample output of SP's version of stat, to see how it can be combined with awk. – Archemar Nov 29 '15 at 19:01
  • 1
    As discussed in your last question unix.stackexchange.com/questions/242841/… , busybox has only basic versions of ls, stat, find, and many other tools. You can use perl, which you have already installed, to work around many of these deficiencies. so, learn perl. – cas Nov 29 '15 at 21:28


 stat -c %Y 
  • you might want to double check with %X and %Z as well.
  • see stat(1) (e.g. man stat)
  • @MarkPlotnick yes right ! this is a typo, I copied it manually. – Archemar Nov 29 '15 at 14:15
  • folks I am quite a novice. can you give me the full command, if I do FMTIME=stat -c %Y it does not work. My stat only allows -f or -L or -t . Should I do stat $FILE ? This will end up with 8-9 lines of text in FMTIME. I need FMTIME to have exactly the same output as in the original command. thanks – csolad Nov 29 '15 at 14:20
  • @csolad No, do stat -c %Y "$FILE". – Mikel Nov 29 '15 at 15:48
  • Mikel as I said in my comment above, my stat only allows -f or -L or -T. so your reply doesn't help in any way unfortunately. – csolad Nov 29 '15 at 19:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.