Skip to main content

All Questions

Tagged with
0 votes
1 answer
1k views

How to determine if a screen is running jobs without attaching to it?

I wrote a zsh script that launches many screen sessions and runs a different command in each of them. When the script is executed there are 72 screens in total, so checking if a job is finished or not ...
Vesnog's user avatar
  • 151
2 votes
4 answers
1k views

How to merge ls commands colors with the output of find or du?

I have a simple alias to list the size of files&folders in cwd. ( including dotfiles in this case , ignoring zero sizes ) du -sh .[!.]* * | sort -hr | grep -v '^0' which can be achieved aswell ...
Nicolai Fröhlich's user avatar
1 vote
2 answers
635 views

tar backup zsh script

Trying to set up a cronjob ran tar script to backup site (without .git and setup folder) every night and upload time stamped archive to Dropbox. It gives me a hard time as archive is created along ...
dzhi's user avatar
  • 117
4 votes
1 answer
3k views

Script-specific autocomplete in shell

I create a lot of little scripts to help me in my every day life. I would like to provide auto-complete for them, specially that I intend to share them with people. Now, I know I can create auto-...
Xananax's user avatar
  • 205
23 votes
2 answers
9k views

Writing shell scripts that will run on any shell (using multiple shebang lines?)

I've just started getting deeper into shell scripting, and I've always just thrown my script in a file, marked it chmod +x and then done /path/to/script.sh and let whatever interpreter is the default ...
swrobel's user avatar
  • 365
5 votes
2 answers
6k views

Efficient way to use all cores in bash or zsh script

If I want to process large number of files with command "do_something" which only can use one core, what's the best way to use all available cores assuming each file can be processed independently? ...
Lissanro Rayen's user avatar
0 votes
1 answer
442 views

zsh expansion modifiers in scripts

I've just found out that ZSH's modifiers only work in interactive scripts, so the following will work correctly on the command line but not from a script (the script ignores the modifier and echoes ...
Gareth's user avatar
  • 317
2 votes
1 answer
7k views

Deleting a file if it exists or not

Here is a part of my zshrc file. ## Most Frequently used settings # ls alias ls='rm .DS_Store; echo --------------${PWD##*/}--------------; ls -1FGu' alias l='ls -A' I want to delete .DS_Store, ...
SurenNihalani's user avatar
2 votes
1 answer
8k views

Creating a link for all files in a directory to home

I am trying to write a small zsh (bash compatible) script to take each file in ~/.oh-my-zsh/links directory and creates a hard link for it in ~. I am not sure how to do this. Would this be correct? ...
SurenNihalani's user avatar
0 votes
3 answers
1k views

High performance perforce sync

I am trying to do p4 sync folder/... It's not very fast and it's using only 2% of the CPU. I am not happy with the performance. I am trying to write a function in bash, given a parameter n, it forms ...
SurenNihalani's user avatar
0 votes
1 answer
153 views

Diff between files in different directories

I have the follow directory structure ./goodboys/a.txt ./goodboys/b.txt ./badboys/a.txt.boy ./badboys/b.txt.boy I am using zsh. I want to diff all *.txt in goodboys with *.txt.boy in badboys. I am ...
SurenNihalani's user avatar
5 votes
2 answers
2k views

How to search *upwards* for file? (reverse find)

I'd like to search "upwards" for a file in shell script, e.g. check $PWD, then $PWD/.., then $PWD/../.., etc. until hitting the root. Before I go and roll my own, is there some builtin bash/zsh/find ...
Joseph Garvin's user avatar
1 vote
1 answer
1k views

Under zsh, looking to use `tr` to search and replace a single character with multiple characters

I want to replace "Blah: whatever" or "Blah/Whatever" with "Blah--Whatever" I have this: NEW=`echo ${OLD} | tr '[:/]' '--'` echo ${NEW} I suppose it's taking the 2 dash characters to mean 1 letter ...
Roy Rico's user avatar
  • 5,948
3 votes
4 answers
3k views

Loop: Start program and kill after time out

for debugging reasons I want to spot one of those bugs showing up just occasionally. Therefore I want to code a while loop in the shell starting the program (if it will segfault => that's what I want)...
math's user avatar
  • 2,653
2 votes
2 answers
2k views

On OS X, how do I start Cocoa emacs *and* bring it to front?

I wrote a little zsh function to allow me to run emacs from the command-line: function emacs() { /Applications/Emacs.app/Contents/MacOS/Emacs $@ & } This works perfectly, but it seems to ...
Jason Baker's user avatar
  • 8,672

15 30 50 per page
1
2