Most Popular
1500 questions
97
votes
8 answers
How do you list number of lines of every file in a directory in human readable format.
I have a list of directories and subdirectories that contain large csv files. There are about 500 million lines in these files, each is a record. I would like to know
How many lines are in each file.
How many lines are in directory.
How many…
Hexatonic
- 1,215
- 2
- 10
- 9
97
votes
2 answers
For loops in zsh and bash
I have noticed there are two alternative ways of building loops in zsh:
for x (1 2 3); do echo $x; done
for x in 1 2 3; do echo $x; done
They both print:
1
2
3
My question is, why the two syntaxes? Is $x iterating through a different type of…
Amelio Vazquez-Reina
- 40,169
- 77
- 197
- 294
97
votes
3 answers
Git submodule shows new commits, submodule status says nothing to commit
In a git repository, I have set up my .gitmodules file to reference a github repository:
[submodule "src/repo"]
path = src/repo
url = repourl
when I 'git status' on this repo, it shows:
On branch master
Your branch is up-to-date with…
Catherine Holloway
- 1,075
- 1
- 7
- 7
97
votes
2 answers
Location of the crontab file
as many (most?) others, I edit my crontab via crontab -e, where I keep all routine operations such as incremental backup, ntpdate, various rsync operations, as well as making my desktop background christmas themed once a year. From what I've…
Jarmund
- 1,068
- 1
- 8
- 11
97
votes
7 answers
How to use `which` on an aliased command?
Like most users, I have a bunch of aliases set up to give a default set of flags for frequently used programs. For instance,
alias vim='vim -X'
alias grep='grep -E'
alias ls='ls -G'
The problem is that if I want to use which to see where my…
Adrian Petrescu
- 1,077
- 1
- 9
- 10
96
votes
4 answers
How do I install htop in mac OS X?
How do I install htop for macOS (OS X)? (The easiest and laziest path)
Ruvenss
- 1,061
- 1
- 7
- 8
96
votes
8 answers
How can I get a formatted date for a UNIX timestamp from the command line
I have a UNIX timestamp and I'd like to get a formatted date (like the output of date) corresponding to that timestamp.
My attempts so far:
$ date +%s
1282367908
$ date -d 1282367908
date: invalid date `1282367908'
$ date -d +1282367908
date:…
Umang
- 1,161
- 1
- 7
- 10
96
votes
11 answers
Remove last character from line
I want to remove last character from a line:
[root@ozzesh ~]#df -h | awk '{ print $5 }'
Use%
22%
1%
1%
59%
51%
63%
5%
Expected result:
Use
22
1
1
59
51
63
5
Özzesh
- 3,549
- 8
- 23
- 25
96
votes
10 answers
How to terminate dead connections from the command line without restarting server
I have some dead connections in an application which enter a hanged state if the client machine is dead. One of the connections is shown as
->192.168.1.214:49029 (ESTABLISHED)
Is there a way to terminate these connections from the Linux command…
Vivek Goel
- 1,273
- 1
- 13
- 11
96
votes
2 answers
Use shared libraries in /usr/local/lib
I have build some libraries from sources, and the files after make install are in /usr/local/lib
For example, in my case I have the file libodb-2.2.so which is in this directory.
However when I launch the executable that has linked with libodb, I…
Stephane Rolland
- 4,147
- 6
- 37
- 49
96
votes
8 answers
Creating a ram disk on Linux
I have a machine with 62GB of RAM, and a trunk that's only 7GB, so I thought I would create a RAM disk and compile there. I am not a Linux expert. I found instructions on the internet to create the RAM disk:
mkfs -q /dev/ram1 8192
but I changed…
Frank
- 961
- 1
- 7
- 3
96
votes
2 answers
How do I copy a symbolic link?
I have a symbolic link to a file in one directory. I would like to have that same link in another directory. How do I copy a symbolic link?
I tried to cp the symbolic link but this copies the file it points to instead of the symbolic link itself.
User
- 2,197
- 2
- 20
- 22
96
votes
2 answers
Bash test: what does "=~" do?
#!/bin/bash
INT=-5
if [[ "$INT" =~ ^-?[0-9]+$ ]]; then
echo "INT is an integer."
else
echo "INT is not an integer." >&2
exit 1
fi
What does the leading ~ do in the starting regular expression?
ragnarok
- 969
- 1
- 7
- 3
96
votes
4 answers
Tmux mouse-mode on does not allow to select text with mouse
I'm using tmux 2.1 and tried to on mouse mode with
set -g mouse on
And it works fine, I can switch across tmux window splits by clicking the appropriate window. But the downside of this is that I cannot select text with mouse. Here is how it looks…
Dmitrii Bundin
- 1,073
- 1
- 7
- 7
96
votes
3 answers
What does the letter 'u' mean in /dev/urandom?
I understand that reads to /dev/random may block, while reading /dev/urandom is guaranteed not to block.
Where does the letter u come into this? What does it signify?
Userspace? Unblocking? Micro?
Update:
Based on the initial wording of the…
Tom Hale
- 28,728
- 32
- 139
- 229