Tag Info

Hot answers tagged

32

You can't use the tar command because the archive isn't a .tar.* file. To uncompress a bzip2 file, use the following command: bzip2 -d enwiki-latest-pages-articles.xml.bz2 This won't preserve the original .bz2 file. If you want to extract it and keep the original, run this command: bzip2 -dk enwiki-latest-pages-articles.xml.bz2 Source: ...


16

Just use bunzip2: bunzip2 enwiki-latest-pages-articles.xml.bz2 And if its a gzip commpressed file: gunzip enwiki-latest-pages-articles.xml.gz


14

You can use the dot (.) to represent the current working directory (CWD) mv file_old_dir .


6

I am going to show some alternate ways using the PWD environment variable and pwd built-in of the shell. You can the use the value of PWD environment variable that stores the name of current working directory: mv file_old_dir "$PWD" Or you can use the pwd built-in of shell that prints the current working directory (basically pwd shows the value of PWD ...


6

With awk: ... | awk '/CPU temp/ {print $4}' with grep: ... | grep -oP '^CPU temp.*=.* \K[0-9]+' with sed: ... | sed -nE 's/^CPU temp.*=.* ([0-9]+).*/\1/p'


5

The most straightforward option would be find: $ cd /usr/lib; find . . ./libxcb-icccm.so.4.0.0 ./libbz2.so.1.0.6 ./libdca.so.0 ./libxcb-composite.so ./libyajl.so ./libswscale.so ./libxvidcore.so.4.3 ./libjasper.so.1 ./libdrm_intel.so.1 ... It has various tests for filtering such as: -type to filter based on type (regular file f, directory d, etc.) ...


5

First install mediainfo with: sudo apt-get install mediainfo You can now use the following oneliner to get the total video time of a directory: find . -type f -exec mediainfo --Inform="General;%Duration%" "{}" \; 2>/dev/null | awk '{s+=$1/1000} END {h=s/3600; s=s%3600; printf "%.2d:%.2d\n", int(h), int(s/60)}' The find command will call mediainfo ...


5

Simplest: cut -d: -f1 /etc/passwd | sort To also view the user(s) information from the terminal type: grep /home /etc/passwd | sort The /home tells grep to drop any lines that do not contain the text /home thereby filtering out many lines that don't have information about users from the results of the command. In Ubuntu the user directories are ...


5

If both orig_folder and temp are on the same physical hard drive, renaming (moving) them is essentially instantaneous. That means you could simply do mv orig_folder foo && mv temp orig_folder && rm -rf foo That will rename orig_folder to foo, then rename temp to orig_folder and finally delete foo. On the same filesystem, the two mv ...


4

You can change the suspend char using stty. In your case, for example, you can disable the "suspend" ability with stty susp undef or change it to for example ctrl-E with stty susp '^E' and you can check it: [romano:~/Downloads/mps] % sleep 1000 ^E [1] + 2681 suspended sleep 1000 1z [romano:~/Downloads/mps] 20 % fg [1] + 2681 continued sleep ...


4

If you want just to sort only the names (after cut) use Rinzwind's answer. If you want to sort the /etc/passwd file alphabetically based on the usernames: sort -t: -k1,1 /etc/passwd


4

You can try cmp. It will compare two files byte by byte. From man cmp: cmp - compare two files byte by byte Although the number of lines must be equals on two files. Also note that cmp will point to the first difference only, to point to the next differences you can skip specific bytes from the start. $ cat foo this is a test $ cat bar this is a test ...


4

You can use the following script to know Total Duration of all video files in a Directory recursively. I have used avprobe in the following script which comes with libav-tools Install libav-tools as, sudo apt-get install libav-tools Save the script as get_video_duration.sh(say). Give it execution permission from a terminal as chmod u+x ...


4

How about: tlp-stat -t | head -4 | tail -1 |cut -c29-30


3

It's not installed by default, but is easily installed from the store.


3

As suggested by steeldriver, you can force both STDIN/STDOUT to be UTF-8: -C on its own (not followed by any number or option list), or the empty string "" for the PERL_UNICODE environment variable, has the same effect as -CSDL. In other words, the standard I/O handles and the default open() layer are UTF-8-fied but only if the locale environment ...


3

Try: rename 's/zip[^.]*$/zip/' /path/to/directory/containing/the/files/* Example: $ ls bar.zip2 egg.zip4 foo.zip1 spam.zip3 test.zip_ $ rename 's/zip[^.]*$/zip/' * $ ls bar.zip egg.zip foo.zip spam.zip test.zip


3

I think for your case, I'd investigate byobu/screen/tmux (I believe byobu is the go-to on ubuntu, screen is more prevalent on other linuxes, and tmux on BSDs). A picture is worth a thousand words here, so sticking 'byobu' into youtube will explain the concept much quicker than I can in words. But they're terminal multiplexers, which allow you to start ...


3

While writing the question, I started playing around with grep. Part of the performance problem is that grep is running a ton of regex searches for every file. These are expensive. We can just do full-string searches without the regex, using the -F argument. find | grep -vFf <( sqlite3 database.sqlite3 'select replace(images, CHAR(124), CHAR(10)) ...


3

I would guess it will be both simpler and faster to just use GLOBIGNORE (assuming your shell is bash anyway): GLOBIGNORE A colon-separated list of patterns defining the set of filenames to be ignored by pathname expansion. If a filename matched by a pathname expansion pattern also matches one of the patterns in ...


2

This multiple rename task is easy to do using pyRenamer from the Ubuntu Software Center. The following screenshot explains how to do it: I know it's not the way to do it in the terminal as you requested, but this is an alternate way of doing it that you may find easier because you can browse to the files to be renamed in the pyRenamer window instead of ...


2

Presumably you want %b. From help printf: In addition to the standard format specifications described in printf(1), printf interprets: %b expand backslash escape sequences in the corresponding argument And: $ printf "%b\n" '\101' A I don't know if it works for Unicode characters in general.


2

With the awk commands in the link you post, you'd get something like this: awk '{printf("%d\n",$0+0.5)}' file Or simpler, use: awk '{printf("%.f\n",$0)}' file I can come up with nothing easier than that ;)


2

You need to install it from the store. Just click the "Ubuntu Store" button at the bottom of the Apps scope, then search for "Terminal" and you should find it.


2

You can use grep to extract the IP addresses, and sort + uniq to count the number of hits: grep -Po '^\d+(\.\d+){3}' filename | sort | uniq -c grep is used to search for text matching a regular expression -o prints only the text that matched the expression, and not the entire line -P enables Perl-style regular expressions ^\d+(\.\d+){3} - a string that ...


1

You have to install it from ubuntu store


1

The descriptions of the options are all given in man dh_make: Single binary (s) The package will generate a single binary .deb package. It is the standard case, so if you don't know what to do, choose this. Arch-Independent (i) The package will generate a single package that is arch- independent. ...


1

You can use the following perl oneliner: perl -i -pe 's/(\d*\.\d*)/int($1+0.5)/ge' file The -i option will automatically change your decimal numbers in-place. The regex \d*\.\d* will ensure that only such numbers will be changed in your original file (i.e other strings will be left untouched)


1

You have to tell perl that the script body contains UTF8 chars: $ perl -w -C -p -e 's/(\p{Devanagari})\./$1।/g' test.txt ಕದಂ.ಬ कदम्ब। $ perl -Mutf8 -w -C -p -e 's/(\p{Devanagari})\./$1।/g' test.txt ಕದಂ.ಬ कदम्ब।


1

Use mmv command (Install it by sudo apt-get install mmv): mmv -n '*.zip*' '#1.zip' First * matches everything before .zip and second * matches everything after .zip and they become as group of matches with back-reference #1 and #2 respectively. And we only keep the first one with .zip at the end. Note: With using -n option, mmv command runs as dry, so ...



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