Most Popular
1500 questions
90
votes
10 answers
How to assign a string value to a variable over multiple lines while indented?
The issue:
I need to assign a variable a value that is decently long.
All the lines of my script must be under a certain number of columns.
So, I am trying to assign it using more than one line.
It's simple to do without indents:
VAR="This…
JamesL
- 1,260
- 1
- 13
- 19
90
votes
11 answers
Execute a specific command in a given directory without cd'ing to it?
Is there a way to execute a command in a different directory without having to cd to it? I know that I could simply cd in and cd out, but I'm just interested in the possibilities of forgoing the extra steps :)
Naftuli Kay
- 38,686
- 85
- 220
- 311
90
votes
3 answers
What happens when I run the command cat /proc/cpuinfo?
What happens when I write cat /proc/cpuinfo. Is that a named pipe (or something else) to the OS which reads the CPU info on the fly and generate that text each time I call it?
slm
- 363,520
- 117
- 767
- 871
90
votes
8 answers
Colors in Man Pages
When I look at a man page in my 'console' (not an xterm) I see some coloration, but I don't get this in my xterm's (e.g. konsole) is there any way I can enable this? hopefully a fairly simple solution?
xenoterracide
- 57,918
- 74
- 184
- 250
90
votes
4 answers
What are the responsibilities of each Pseudo-Terminal (PTY) component (software, master side, slave side)?
I am trying to figure out how a tty works1 (the workflow and responsibilities of each element). I have read several interesting articles about it, but there are still some blurry areas.
This is what I understand so far:
The emulated terminal makes…
Pierre-Jean
- 2,229
- 1
- 15
- 18
90
votes
6 answers
Why does `ESC` move the cursor back in vim?
In vim, when I hit ESC to return to command mode, the cursor moves one character to the left. This is not what I would hope for, occasional I immediately hit l to move back to that spot, perhaps to delete a character.
Is there a reason for this…
Eric Wilson
- 4,622
- 9
- 32
- 43
90
votes
1 answer
Command history in Zsh
How does Zsh keep track of command history?
I see two files in my home directory: .zhistory and .zsh_history. What is the difference between them? The files seem to contain all of my history. Does Zsh keep appending lines to one of them forever?…
Amelio Vazquez-Reina
- 40,169
- 77
- 197
- 294
90
votes
7 answers
How to avoid password prompt with rsync (and without using public keys)?
I need to execute rsync, without it prompting me for password.
I've seen in rsync manpage that it doesn't allow specifying the password as command line argument.
But I noticed that it allows specifying the password via the variable…
Dor
- 2,445
- 7
- 33
- 32
89
votes
3 answers
scp and compress at the same time, no intermediate save
What is the canonical way to:
scp a file to a remote location
compress the file in transit (tar or not, single file or whole folder, 7za or something else even more efficient)
do the above without saving intermediate files
I am familiar with shell…
Robottinosino
- 5,271
- 12
- 39
- 51
89
votes
5 answers
In bash, is it possible to use an integer variable in a brace expansion
I have the following bash script:
#!/bin/bash
upperlim=10
for i in {0..10}
do
echo $i
done
for i in {0..$upperlim}
do
echo $i
done
The first for loop (without the variable upperlim in the loop control) works fine, but the second for loop (with…
Andrew
- 16,315
- 34
- 73
- 77
89
votes
13 answers
Tips for remembering the order of parameters for ln?
I have used ln to write symbolic links for years but I still get the order of parameters the wrong away around.
This usually has me writing:
ln -s a b
and then looking at the output to remind myself.
I always imagine to be a -> b as I read it when…
Zhro
- 2,495
- 4
- 28
- 45
89
votes
3 answers
What do the "buff/cache" and "avail mem" fields in top mean?
Within the output of top, there are two fields, marked "buff/cache" and "avail Mem" in the memory and swap usage lines:
What do these two fields mean?
I've tried Googling them, but the results only bring up generic articles on top, and they don't…
user48923
89
votes
6 answers
How do I quit from vi?
I'm new to vi. I started vi on my Ubuntu machine and I can't quit. I see the editor and I can write text, at the bottom line there is a label "recording".
How do I quit the vi editor?
Jonas
- 1,593
- 4
- 19
- 22
89
votes
6 answers
How to exit a shell script if one part of it fails?
How can I write a shell script that exits, if one part of it fails?
For example, if the following code snippet fails, then the script should exit.
n=0
until [ $n -ge 5 ]
do
gksu *command* && break
n=$[$n+1]
sleep 3
Weylyn
- 915
- 1
- 6
- 3
89
votes
5 answers
How to recursively remove execute permissions from files without touching folders?
I made a backup to an NTFS drive, and well, this backup really proved necessary. However, the NTFS drive messed up permissions. I'd like to restore them to normal w/o manually fixing each and every file.
One problem is that suddenly all my text…
gaazkam
- 1,400
- 3
- 10
- 17