Tag Info

Hot answers tagged


You should understand that bash is just an execution environment. It executes commands that you call - it's not the business of the shell to even know what the command does, you can call any executable you want. In most cases, it's not even clear what an undo would do - for instance, can you "unplay" a movie? Can you "unsend" an e-mail? What would "undo ...


With tr: echo "Thhiisss iisss mmyyy nameeee" | tr -s 'a-z' Explanation: The -s switch of tr "squeezes" repeat characters. As shown, the switch can be used with a range of characters: a to z.


No, there is no such thing as an "undo" in Bash, sorry. This is why you should double-check your commands or test them on unimportant files first (if that's possible). And triple-check if you're doing things as root ;)


No, there is no generic undo, but some consequences are more reversible than others. Take for example rm: it's essentially used for two purposes - avoiding clutter and freeing space up for new files. With a bit of luck you can retrieve the contents of the file using tools like extundelete, because only the pointer to the start of the file is overwritten when ...


Applications that provide an 'undo' feature do so by maintaining a history of actions taken and either a method of reversing the action or a snapshot of the state of an object to restore a previous state. Commands executed in a shell perform direct actions or execute commands to perform actions. The shell itself would not have the ability to undo the ...


On a GNU system you'll need to use sed or similar if your locale uses multibyte characters (as jimmij suggests) because GNU tr can only reference a character per byte. In an ASCII locale you can remove all duplicates w/ tr like: LC_ALL=C tr -s '\0-\255' <input So... echo Thhiisss iisss mmyyy nameeee| LC_ALL=C tr -s '\0-\255' ...prints... This is my ...


One way with sed: sed ':X;s/\(.\)\1/\1/g;tX' or even simpler: sed 's/\(.\)\1*/\1/g' (thanks Costas and mikeserv for comments).


So here we do have to pass the file name twice in the function. They are not quite the same thing as you notice by observing that one of them is used as the argv[0] value. This doesn't have to be the same as the basename of the executable; many/most things ignore it and you can put whatever you want in there. The first one is the actual path to the ...


You don't have to pass the file name twice. The first one is the file that is actually exec'ed. The second argument is what should be the argv[0] of the process, i.e. what the process should see as its name. E.g. if you run ls from the shell, the first argument is /bin/ls, the second is just ls. You can exec a certain file and call it something else via ...


Try tr: echo "Thhiisss iisss mmyyy nameeee" | tr -s 'hismye'


You created a directory called backupunder the directory where you were at that moment. However you moved the file myfile.tar.gz to /backup. The / means that you moved the file to a new file called backup under directory /. The only thing you did was rename myfile.tar.gz to backup and put it under /.


shopt -s checkwinsize in bash can fix this problem sometimes, it arises when the remembered window size differs from the current size. Granted this is usually only an issue with graphical terminals, e.g. konsole mate-terminal, etc.


Could be a carriage return (\r) in the destination file name. EDIT: Any chance you previously had your terminal settings messed up? This can happen if you by accident cat a binary file on your terminal. One way to fix that is stty sane Another reason might be that a SIGWINCH got lost when you resized the terminal window. In that case, another resize ...


$ ssh-copy-id Usage: /usr/bin/ssh-copy-id [-h|-?|-n] [-i [identity_file]] [-p port] [[-o <ssh -o options>] ...] [user@]hostname So in your case simply use: $ ssh-copy-id -i ~/.ssh/id_rsa.pub -p 22001 user@ Because of your usage of quotes, the -p 22001 part became part of the hostname which explains the error you got.


No, there is not, but if, say you messed around with a root privileged directory and somehow screwed something up, than your best bet is to save all the files you can to a USB Drive or a SD Card and reset your operating system from the ISO file (if you still have it, if not you can get another one offline...). If you deleted something you can, as wraeth ...


The takeaway is that argv[0] can be set to anything (including NULL). By convention, argv[0] will be set to the path the executable was started as (by the shell process when it does the execve()). If ./foo and dir/bar are two different links (hard or symbolic) to the same executable, then starting the program from the shell using the two paths will set ...

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