close all the instances of google chrome except first
Solution 1:
To close all windows except the frontmost window, run:
osascript -e 'tell app "Google Chrome" to close (windows 2 thru -1)'
To close all windows except the window opened first, run a script like this in AppleScript Editor:
tell application "Google Chrome"
if number of windows < 2 then return
set min to id of window 1
repeat with w in windows 2 thru -1
if id of w < min then set min to id of w
end repeat
close (windows where id is not min)
end tell
"Instances" are usually called windows in OS X, and windows are not separate instances of a process like the instances opened by open -n
.