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 ...
Zanna's user avatar
  • 70.4k
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: ....
Zanna's user avatar
  • 70.4k
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 ...
muru's user avatar
  • 197k
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-...
musicman1979's user avatar
  • 1,149
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 ...
muru's user avatar
  • 197k
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
Artur Meinild's user avatar
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:...
Hannu's user avatar
  • 5,366
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 ...
Raffa's user avatar
  • 31.9k
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 ...
Raffa's user avatar
  • 31.9k

Only top scored, non community-wiki answers of a minimum length are eligible