Most Popular

1500 questions
223
votes
12 answers

How do you move all files (including hidden) from one directory to another?

How do I move all files in a directory (including the hidden ones) to another directory? For example, if I have a folder "Foo" with the files ".hidden" and "notHidden" inside, how do I move both files to a directory named "Bar"? The following does…
Cory Klein
  • 18,911
223
votes
12 answers

How to scroll in a terminal using keyboard?

How can I scroll in bash using only the keyboard? If it's not possible in bash, are there any other shells that support this?
223
votes
9 answers

tar: Removing leading `/' from member names

root@server # tar fcz bkup.tar.gz /home/foo/ tar: Removing leading `/' from member names How can I solve this problem and keep the / on file names ?
superuser
  • 2,331
223
votes
1 answer

How to skip "permission denied" errors when running find in Linux?

Possible Duplicate: How do I remove “permission denied” printout statements from the find program? When I run this command in Linux (SuSE): find / -name ant I get many error messages of the form: find: `/etc/cups/ssl': Permission denied Does…
user710818
  • 2,469
  • 3
  • 18
  • 12
222
votes
9 answers

ssh-add complains: Could not open a connection to your authentication agent

I've been trying to get ssh-add working on a RaspberryPi running Raspbian. I can start ssh-agent, when I do it gives the following output into the terminal: SSH_AUTH_SOCK=/tmp/ssh-06TcpPflMg58/agent.2806; export SSH_AUTH_SOCK; SSH_AGENT_PID=2807;…
222
votes
7 answers

Sort based on the third column

I'm facing a huge 4-columns file. I'd like to display the sorted file in stdout based on its 3rd column: cat myFile | sort -u -k3 Is that enough to perform the trick?
user1058398
  • 4,188
221
votes
11 answers

How to check if a shell is login/interactive/batch

I think I understand the differences between an interactive, a login and a batch shell. See the following links for more help: What is the difference between a 'Login' and an 'Interactive' bash shell (from the sister site: Server Fault) Difference…
221
votes
9 answers

Move folder content up one level

I have a directory that is unpacked, but is in a folder. How can I move the contents up one level? I am accessing CentOS via SSH.
whatshakin
221
votes
1 answer

Human readable memory sizes in top?

Is there an option in top to show memory sizes in human readable format? Example: PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND 3960 phil 20 0 1347280 383112 30316 S 0.0 9.5 …
220
votes
5 answers

Precedence of the shell logical operators &&, ||

I am trying to understand how the logical operator precedence works in bash. For example, I would have expected, that the following command does not echo anything. true || echo aaa && echo bbb However, contrary to my expectation, bbb gets printed.…
Martin Vegter
  • 358
  • 75
  • 236
  • 411
219
votes
11 answers

Tool to monitor folder for new files and run command whenever new file is detected

How can I immediately detect when new files were added to a folder within a bash script? I would like the script to process files as soon as they are created in the folder. Are there any methods aside from scheduling a cron job that checks for new…
norq
  • 4,081
219
votes
6 answers

Where do I put my systemd unit file?

I read that there are two folders for unit files (not in user mode). /usr/lib/systemd/system/: units provided by installed packages /etc/systemd/system/: units installed by the system administrator Conflicting with this understanding is the answer…
Jonathan Komar
  • 6,424
  • 7
  • 35
  • 53
218
votes
7 answers

Copy specific file type keeping the folder structure

I have a folder structure with a bunch of *.csv files scattered across the folders. Now I want to copy all *.csv files to another destination keeping the folder structure. It works by doing: cp --parents *.csv /target cp --parents */*.csv"…
Mojo
218
votes
11 answers

List files sorted numerically

I have a bunch of files from log1 to log164. I'm trying to LIST the directory (sorted) in a UNIX terminal but the sort functions are only providing the format like this: home:logs Home$ ls -1 |…
Rabiani
218
votes
8 answers

Why is looping over find's output bad practice?

This question is inspired by Why is using a shell loop to process text considered bad practice ? I see these constructs for file in `find . -type f -name ...`; do smth with ${file}; done and for dir in $(find . -type d -name ...); do smth with…
don_crissti
  • 82,805