4
votes
Cut folder names out of string
Oh okay, here is a sed answer
$ echo 'TRUE|/home/linux/test|(null)|' | sed -r 's#.*/([^|]+)\|.*#\1#'
test
Explanation:
-r use extended regex
s#...#..# find and replace using # as an alternative ...
3
votes
How to fix "chmod" permissions after running "chmod 222 /bin/chmod"?
You can execute a file that lacks execute permission simply by calling its interpreter. Here's a very simple example:
$ touch file
$ stat -c '%a' file
664
$ echo 'echo hello' > file
$ ./file
bash: ....
3
votes
Copy a folder name into the name of its files
If both directories are located in the same parent directory, in Desktop as an example, you can use something like:
cd ~/Desktop
rename -n 's,^(.*)/,Pictures/$1-,' Mexico/*.jpg Spain/*.jpg
Note that ...
2
votes
Accepted
I followed a solution procedure on AskUbuntu, logged out and now all my data is gone (no guest account)
Problem
User home directory and everything in it were deleted
Explanation:
The command rm -rf ~ performs the following actions:
rm: This is the command used to remove files or directories in Unix-...
2
votes
Accepted
What are zsh equivalent to bash's shopt -s globstar and shopt -s dotglob?
Recursive globbing is the default in zsh, it doesn't need to be enabled. The ** glob is simply syntactic sugar here:
A pathname component of the form ‘(foo/)#’ matches a path consisting
of zero or ...
2
votes
How to stop wget command?
Kill the wget command by using pkill, and sending the TERM signal (default for the command):
pkill -x wget
If this doesn't work, send the KILL signal instead:
pkill -9 -x wget
1
vote
Accepted
changing grep command --color from red to another color
The simple solution:
Add --color=always to the grep options... then pipe the result into
| sed -re 's/31m/32m/' and you will get green text instead of the red.
Another way is described in the man page:...
1
vote
Copy a folder name into the name of its files
In a Bash shell loop with mv:
for f in */*; do
if [ "${f%/*}" != "Pictures" ]; then
echo mv -nv -- "$f" "Pictures/${f%/*}${f#*/}"
fi
done
You'll ...
1
vote
Changing Linux file names to NTFS-compatible file names
With Perl's rename:
rename -n 'y/\\: /__\-/ if -f' *
... where -n is for a dry-run (to actually rename files, remove it or change it to -v for verbosity), y will translate each character in the ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
command-line × 22922bash × 5407
scripts × 2735
gnome-terminal × 868
text-processing × 862
permissions × 713
server × 702
apt × 673
ssh × 565
14.04 × 543
sudo × 511
software-installation × 491
python × 488
files × 485
16.04 × 450
gnome × 442
networking × 428
directory × 417
grep × 366
18.04 × 361
shortcut-keys × 357
12.04 × 355
sed × 351
package-management × 335
find × 327