All Questions
90
questions
80
votes
9
answers
69k
views
How do I get ls --color=auto to work on Mac OS X?
I'm trying to move my bash configuration from Ubuntu to Mac OS X and it looks like ls is slightly different. For instance, it won't accept the --color option.
How do I get this to work?
46
votes
1
answer
13k
views
What's an elegant way to copy the creation and modification dates of a file to another file?
How can I set the time information of a file to be the same as of another file on OSX / Linux?
41
votes
6
answers
107k
views
How does Mac's command line compare to Linux?
I love Ubuntu Linux - especially the commmand line. But I have to admit that, at least for now, Windows is more user-friendly - there's more software for it, more drivers, and more stuff just works.
...
18
votes
3
answers
10k
views
How to list directories names but not their contents, in *N*X?
If I do a simple ls specifying a filename pattern, like ls A*, for directories that match the pattern, it will enter the directory and give the full listing, but how could I get just the listing for ./...
17
votes
3
answers
22k
views
How to force ls terminal command to show results in Bytes while I have set the default to ls -h in bash profile?
I am following the snippet here to improve my terminal command in Mac OSX.
It sets the default value of ls results to human-readable by exporting alias ls='ls -GFh' to bash profile file. This is very ...
15
votes
3
answers
29k
views
If, else based on command piped to grep
I can't figure out how to make this (what supposed to be simple) script to work. Basically what I want, to run different stuff based on the state of my Parallels vm, something like this:
if [ prlctl ...
12
votes
3
answers
33k
views
What is the difference between terminal and bash? [duplicate]
When I open Terminal Window in Mac OS X, I can type bash and hit enter and I will see:
Last login: Fri Feb 20 14:30:56 on ttys000
Korays-MacBook-Pro:~ koraytugay$ bash
bash-3.2$
I can for example ...
11
votes
2
answers
6k
views
How do I make "bash -x" (debug mode) recurse into sourced scripts?
I'm trying to debug what bash does on login initialization for Linux. I've read that "bash -x" will make bash print out what it's doing, but it doesn't print commands in sourced files like "set -x" ...
10
votes
3
answers
7k
views
Expanding globs in xargs
I have a directory like this
mkdir test
cd test
touch file{0,1}.txt otherfile{0,1}.txt stuff{0,1}.txt
I want to run some command such as ls on certain types of files in the directory and have the * (...
9
votes
3
answers
78k
views
How to run a bash script via absolute path?
I have a file:
/Users/danylo.volokh/test/test_bash_script.sh
Content is very simple:
#!/usr/bin/env bash
echo "-- print from script"
I'm in folder "danylo.volokh"
This command runs fine:
Danilos-...
8
votes
6
answers
3k
views
In Bash (Mac/Linux terminal shell), can the up and down arrow keys be made to function as they do in text editors?
In text editors, if I press the up and down arrow keys, it moves the cursor between lines of text.
In Bash, if I’m typing a long command that spans multiple lines and I press the up and down arrow ...
8
votes
3
answers
571
views
How to have a better view when typing out directories in terminal?
I am currently using a Mac and learning to use the terminal, but the question applies to Linux systems as well.
I would like to ask, when typing out paths in the terminal/command line, is there a way ...
8
votes
2
answers
18k
views
Can `ls` be set to only list the first X files/directories?
I'm trying to make a command which only displays the first 30 files when the ls command is invoked. I found this method...
ls | head -30
... but it ends up spitting out the files in one long list, ...
7
votes
2
answers
5k
views
Bash autocomplete for different directories
I've played with bash autocomplete now for a while, but couldn't find a solution for my problem. I have a project directory with subfolders like this:
projects/ruby/project1
projects/ruby/project2
...
5
votes
10
answers
15k
views
Is there a simpler form of find . -name "*substring_of_filename*" on Mac OS X and Linux?
On Mac OS X or Linux, is there a simpler form of the command
find . -name "*substring_of_filename*"
which is to find all files having names containing substring_of_filename within the current ...