Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added "cd -" #56

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1034,6 +1034,16 @@ find . -type f -empty -delete
find . -type f | wc -l
```

##### List all files with name [FILE] under /
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

searching through on entire system can be very resource-intensive and time-consuming, and should be done with caution. I tend not include this example here, as previous examples show how to search file with name.

```bash
find / -name [FILE] 2>&1 | grep -v 'Permission denied'

# 2>&1 redirects STDERR outputs to STDOUT which is piped
# to the grep inverse filter (-v) filter command.
# Thus, any errors are surpressed, mainly due to access attempts
# on priviliged directories.
```

## Condition and loop
[[back to top](#handy-bash-one-liners)]

Expand Down Expand Up @@ -3180,6 +3190,15 @@ cd $(mktemp -d)
# for example, this will create a temporary directory "/tmp/tmp.TivmPLUXFT"
```

##### Quickly return to last working directory
Copy link
Owner

@onceupon onceupon Aug 29, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can use

Return to the previous directory
cd -

i suggest removing the comments below as they are hard to understand:

# example that will get you back to home directory:
# cd ~
# cd /tmp/tmp.TivmPLUXFT
# cd -

as most oneliners are quick

```bash
cd -
# example that will get you back to home directory:
# cd ~
# cd /tmp/tmp.TivmPLUXFT
# cd -
```

##### Make all directories at one time!
```bash
mkdir -p project/{lib/ext,bin,src,doc/{html,info,pdf},demo/stat}
Expand Down
2 changes: 0 additions & 2 deletions _config.yml

This file was deleted.