Score:0

Extract one column of strace -c

in flag

I am trying to get the system call names for common commands and don't have list of commands.
Do you have any idea how can I get list of system calls for some commands.
Finally I tried to do such thing manually for each command. I run strace -c ls and output is something like this:

Canzanese_QRS_2015.pdf         mal-api-2019.zip
JetBrains.PyCharm.2021.1.2.tar.gz  vfvw7g8s8h-2.zip
% time     seconds  usecs/call     calls    errors syscall
------ ----------- ----------- --------- --------- ----------------
 18.18    0.000202          17        12           mprotect
 15.21    0.000169          10        17           mmap
 12.15    0.000135          15         9           openat
 10.17    0.000113          10        11           close
  8.28    0.000092           9        10           fstat
  6.39    0.000071          10         7           read
  4.50    0.000050           6         8         8 access
  3.78    0.000042          21         2         2 statfs
  3.06    0.000034          34         1           prlimit64
  2.88    0.000032          16         2           ioctl
  2.70    0.000030          10         3           brk
  2.52    0.000028          14         2           rt_sigaction
  2.16    0.000024          24         1           munmap
  1.62    0.000018           9         2           write
  1.53    0.000017           9         2           getdents
  1.26    0.000014          14         1           rt_sigprocmask
  1.26    0.000014          14         1           set_robust_list
  1.17    0.000013          13         1           arch_prctl
  1.17    0.000013          13         1           set_tid_address
  0.00    0.000000           0         1           execve
------ ----------- ----------- --------- --------- ----------------
100.00    0.001111                    94        10 total

Now how can I extract the last column which is system call names and do you have any idea how can I automate this task for some other commands and save it to a CSV file?

Thanks in advance

Score:0
in flag

You could use awk. Something like this:

strace -c ls 2>&1 | awk -v p=0 \
  '{ if ($1 ~ /[\-]{6}/ ) { p = p + 1 } else if ( p == 1 ) { print $NF }}'
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.