Tag Info

Hot answers tagged

13

There is no way to "roll back" shell commands. If you removed a file using rm command, you can only try to restore it using testdisk or a similar software. Some of shell commands can be rolled back by other shell commands. For example, if file.txt did not exist, command echo "bla bla bla" > file.txt can be rolled back by rm file.txt If file.txt ...


10

There is a very easy and handy way: Using script Start the command script Start your script If your script is finished, stop script via Ctrl-D Check the output in the default output file typescript To start your command in one step with script, use the parameter -c -c COMMAND Run the COMMAND rather than an interactive shell. This makes it ...


9

If unzip would have adhered to the pipes and filters architectural style characteristic of Unix, then one would expect to be able to do this by piping the output of wget into the input of unzip: wget -O - http://www.test.com/test.zip | (cd destination-folder && unzip -) Where the the dash after -O means standard output, the dash after unzip means ...


8

You need more than one step: Go into your destination folder cd destination Download the file wget www.test.com/test.zip Extract the file unzip test.zip To use only one command use a script: #!/bin/bash wget -P "/tmp" "$1" filename=$(awk -F'/' {print $NF}) unzip "$filename" -d "$2" rm "/tmp/$filename" Open an editor to create a new file ...


7

if you normally run your script with foo.sh, try running it (assuming it's a bash script) with bash -x foo.sh. If you want everything redirected to file, try bash -x foo.sh > file.log 2>&1 (note I'm redirecting stderr as well, remove the 2>&1 if you don't want this). If you also want to see what's going on, bash -x foo.sh 2>&1 | tee ...


6

In general, a shell command could do anything to the system, and there is no omnipotent undo mechanism within Ubuntu. However, if you run Ubuntu as a guest inside a virtual machine, you could take a snapshot of the virtual machine, which would give you the ability to rollback to the snapshot.


6

Using bash brace expansion : cat SomeFile{1..100}.dcd >final_file You can have a check at first to see which files it is being expanded to by : echo SomeFile{1..100}.dcd Here {1..100} will be expanded to 1,2,3....100. Example : $ echo SomeFile{1..5}.dcd SomeFile1.dcd SomeFile2.dcd SomeFile3.dcd SomeFile4.dcd SomeFile5.dcd


6

From bash(1) history [n] With no options, display the command history list with line numbers. Lines listed with a * have been modified.


6

The package, appropriately, is called command-not-found. The integration with bash for this package is part of the bash package itself, and unless you modified /etc/bash.bashrc, should work if you have this package installed. If you're using zsh, then add to /etc/zshrc: . /etc/zsh_command_not_found


4

muru's answer is right that the package is called command-not-found. It basically provides a python script /usr/lib/command-not-found that actually does the main job. But the messages that you get in Ubuntu is actually defined by a function that actually exploits command-not-found's properties. Its called command_not_found_handle and resides in ...


4

You can't do this using the shell's field splitting. Adjacent whitespace characters from IFS are parsed together, so you cannot use field splitting to distinguish between adjacent whitespace IFS characters. From the standard (Shell and Utilities, section 2.6.5): Each occurrence in the input of an IFS character that is not IFS white space, along with any ...


3

Using a custom command for your mate-terminal profile, eg: sh -c "cd your_folder; exec bash" Replace your_folder with your preferred folder and bash with your shell if you need another one than bash The terminal in action If you made a mistake use dconf-editor to correct your problem: sudo apt-get install dconf-editor Start dconf-editor ...


3

It seems you have & somewhere in your url, hence the shell is sending the process to background. To solve this, quote the url. For example, if you use : curl https://www.example.com/myscript/foo&bar the shell will treat the url as https://www.example.com/myscript/foo and & after that will cause the curl https://www.example.com/myscript/foo ...


3

Installing express globally generally isn't a good idea, the way most node modules work is by being installed on a per-repo basis so anyone can recreate the environment by running npm install. Thus the recommended way to install express is to run npm install express --save, which will not only download the module but also create an entry in the project's ...


3

That's a job for join: join -t, -j1 -o 2.2,1.2,1.3 <(sort file1) <(sort file2) -t specifies the input and ouput separator -j1 is the join field (in both files the first one) -o ... the format of the output as desired in the question


3

This is something awk handles very well by reading one file in memory and then replacing the items in the other one: $ awk -F, -v OFS="," 'FNR==NR {a[$1]=$2; next} {$1=a[$1]}1' f2 f1 new order,tested test,12345 new quote,test explore,34567 The idea is to store the values from file2 in an array values[file1]=file2. Then, when reading the file1 we replace ...


3

As far as I know, it is not possible to search sub strings of all possible commands at a time. You do though have the option of searching for sub strings of previously typed commands by using Ctrl+R and then typing your sub string. You can press Ctrl+R again to cycle through the previously typed commands containing this sub string


3

using find and sort find . -maxdepth 1 -type f -name "*.dcd" | sort -V


3

Tint2 is installed, because you have executed the command below sudo apt-get install tint2 The folder ~/.config/tint2 is only for configuration files. The default configuration is in /etc/xdg/tint2/tint2rc Create your own configuration with tintwizard. Save the configuration as ~/.config/tint2/tint2confrc and start tint2 with, eg: tint2 -c ...


2

XML is ok, parse is via awk, E.G.: location curl http://w1.weather.gov/xml/current_obs/KRAP.xml | \ awk -F'[<|>]' '/<location>/ {print $3}' Output Rapid City, Rapid City Regional Airport, SD location and weather curl http://w1.weather.gov/xml/current_obs/KRAP.xml \ | awk -F'[<|>]' '/<location>|<weather>/ {print ...


2

Simply start your command with sudo rights: sudo your_python_script And NEVER use your password in a parameter.


2

perl can also use the expansion syntax in loops: perl -e 'print "SomeFile$_.dcd " for 1..100' > foo.txt


2

Back-up important files (if you have any) after booting from a live-cd, then reinstall system. This is the only option that I know of.


2

zsh might be able to get you halfway there: For me, zsh seems to prefer prefix completions (file<tab> will get me file filefrag file-roller, -file<tab> will get me apt-file desktop-file-install ecryptfs-rewrite-file grub-file ...). I don't understand the completion system well enough to make zsh do substring matching even if prefix matching ...


2

Nasal demons.1 man ps says (emphasis mine): comm COMMAND command name (only the executable name). Modifications to the command name will not be shown. A process marked is partly dead, waiting to be fully destroyed by its parent. The output in this column may ...


2

The correct command is sudo su -c 'tar zcvf yourname.tar.gz /etc /var' or simply sudo tar zcvf yourname.tar.gz /etc /var And you forgot the space characters in your command: su -c 'tar zcvf yourname.tar.gz/etc/var/' ^ ^-- Missing SPACE -- Missing SPACE Your PDF has a very bad ...


2

How about defining a custom bash function to do the job : move () { mv -- "$1" "$2"; cd -- "$_"; } put this move function at the end of your ~/.bashrc file. Run the function as move somefile somepath $1 is the first argument to the function (somefile) $2 is the second argument (somepath) $_ expands to the last argument of the previous command ($2 in ...


2

1. The command to type a phrase You can do that by using xdotool, which is not on your system by default. Install it first: sudo apt-get install xdotool Then the command to (literally) type a text phrase is: xdotool type 'This is a test to see if all works fine. If it works this text is typed.' The text will be typed in the frontmost window. Adding ...


2

It seems that you're trying to delete the folder from within the folder itself and giving a non-existing path for rm to delete. Do something like: cd ~/tmp sudo rm -rf remaster-iso


2

That is almost certainly not a dedicated program but just a part of Unity. I know this is the case for Cinnamon for example. As an alternative, you can set the hot corner to launch a terminal. That's basically the same thing except that you'll have to close the terminal manually. In the specific case of cinnamon, what is run is a javascript script. ...



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