Get list of static libraries used in an executable

Since ldd lists only the dynamic libraries, is there a way to extract the information about the static libraries used to create the executable? Answer ldd <exe filename> shows dynamically linked libraries nm <exe filename> shows the symbols in the file. To see which symbols come from static libraries requires running nm against those libraries … Read more

Close Terminal window from within shell script (Unix)?

Is there a way to close a Terminal window from within a shell script? I have a .command file that should just get out of the way once it’s done. Answer Using exit 0 will cleanly terminate the script. Whether Terminal window stays open is user-configurable. The default is to always stay open. To change … Read more

How to tail all the log files inside a folder and subfolders?

In Linux, using the command tailf, how can I tail several log files that are inside a folder and in the subfolders? Answer To log all the files inside a folder, you can go to the folder and write tail -f *.log To add the subfolders to the tailf command, use tail -f **/*.log Of … Read more

How do I kill this tomcat process in Terminal?

Using ps -ef | grep tomcat I found a tomcat server that is running. I tried kill -9 {id} but it returns “No such process.” What am I doing wrong? Here’s an example: Admins-MacBook-Pro:test-parent tom.maxwell$ ps -ef | grep tomcat 2043706342 39707 39695 0 3:40PM ttys000 0:00.00 grep tomcat Admins-MacBook-Pro:test-parent tom.maxwell$ kill -9 39707 -bash: … Read more

How to write a shell script that runs some commands as superuser and some commands not as superuser, without having to babysit it?

I want to write a shell script to automate a series of commands. The problem is some commands MUST be run as superuser and some commands MUST NOT be run as superuser. What I have done so far is something like this: #!/bin/bash command1 sudo command2 command3 sudo command4 The problem is, this means somebody … Read more

How to pipe Node.js scripts together using the Unix | pipe (on the command line)?

I see how to pipe stuff together using Node.js streams, but how do you pipe multiple scripts together using the Unix |, given that some of these scripts can be async? $ ./a.js | ./b.js Example: a.js (chmod 0755) #!/usr/bin/env node setTimeout(function(){ console.log(JSON.stringify({ foo: ‘bar’ })); }, 10); b.js (chmod 0755) #!/usr/bin/env node console.log(process.argv); This … Read more