Tag Info

New answers tagged

0

After all I occured it was memory problem. I didn't set maximum memory for Jetty so it tried to allocate 1/4 of all memory. Also I have found final solution for such problems here: OOM killer not working?


0

You have installed a JRE (Java Runtime Environment) and you need a JDK (Java Development Kit). /bin/javac and /bin/jar are included in the JDK package. Therefore in your case: sudo apt-get install openjdk-7-jdk


1

Not with aliases, use functions instead. From the Bash man page: ALIASES [...] There is no mechanism for using arguments in the replacement text. If arguments are needed, a shell function should be used (see FUNCTIONS below). So your function could be: function dim () { cd ~jason/Documents ; vim $* ; cd - ;}


2

No, you can not do that using shell aliases. You need to use a function. Here is a simple function to do the job : dim() { cd /home/jason/Documents vim "$1" cd } The function dim will take a file name as argument. You can put this code snippet at the end of your ~/.bashrc file and then run it as: dim file.txt Replace file.txt with any file name you ...


3

The problem is that as you are using no quoting, you need to escape both the shell and the regular expression interpreter both to interpret . as literal. That's the reason why quoting is important. Your first pattern would work if you just use quotes around it : apt-file search --regexp '.*ssl.*\.so.*' The main thing to note that our final goal is to let ...


1

If you don't use a quoted pattern, you have to escape the backslash for the RegEx: apt-file search --regexp .*ssl.*\\.so.* With a quoted pattern, you don't need that: apt-file search --regexp '.*ssl.*\.so.*' Example $ apt-file search --regexp .*ssl.*\\.so.* > ~/tmp/bar $ apt-file search --regexp '.*ssl.*\.so.*' > ~/tmp/foo $ diff foo bar | wc ...


4

You need a double backslash \\ because the single backslash is not only the regex escape character but also the one your shell uses. E.g. you escape the dot, which on shell level just interprets to a regular dot, that is then passed to apt-get and machtes every character (as a regular dot usually does). So the answer is, first the string is interpreted by ...


2

Using perl perl -ne 'exit if ($start == 1 && /}/ ); if ($start == 1) {s/\s*([0-9]|\w+)(,|)/$1/g; printf "%s",$_}; $start=1 if (/'"$vovar"'/);' <your_input_file> Explanation exit if ($start == 1 && /}/ ); Exit the script if there is an } if VARIABLES (vovar) is passed if ($start == 1) {s/\s*([0-9]|\w+)(,|)/$1/g; printf "%s",$_} ...


0

$1 is the first argument to a script and you are not passing an argument to it in the example above.. You could make this work by either making a file_count.sh script: #!/bin/sh ssh user@host "grep \"SearchTerm $1\" file.txt \ | sed 's/^.*SearchTerm $1,//g' | sort | uniq -c | sort -nr" or another idea is to make a bash alias (or equivalent with ...


1

Using awk or gawk awk '/@<TRIPOS>BOND/,/@/ {getline; if ($_ ~ /^@/) {printf "%s:%s\n",$_,FILENAME; system ("mv \""FILENAME"\" <bad_files>/$(basename \""FILENAME"\")")} exit}' <file_name> Explanation /@<TRIPOS>BOND/,/@/ We need only the block between @<TRIPOS>BOND and the next line starting with @ getline Read the next ...


2

Using gawk var=($(gawk '/{/,/}/ {if ($0 ~ /copy/) {match ($0, "[[:alpha:]]+", a); printf "%s\n",a[0]}}' <your_file>)) Using perl var=($(perl -ne 'if (/copy/) {s/\s*([[:alpha:]]*).*/$1/g; printf "%s\n",$_}' <your_file>)) Example awk $ var=($(gawk '/{/,/}/ {if ($0 ~ /copy/) {match ($0, "[[:alpha:]]+", a); printf "%s\n",a[0]}}' foo)) $ ...


3

awk method: ARRAY=($(awk 'BEGIN{ORS=" "} /SYNTAX/ && /INTEGER/,/MAX-ACCESS/ {gsub(/SYNTAX|INTEGER|MAX-ACCESS.*|[[:blank:]]|{|}/,"");gsub(/\(/," (");for (i=1;i<=NR;i++) {if ($i~/\(|\)/) $i="" };print}' testfile.txt)) Explanation: We set up ARRAY=(…) structure, with command substitution $(…) within it to catch output of inner awk command into ...


6

The command after the pipe symbol gzip -c > /sql/mybackup.sql.gz is running on your local machine. You should use /usr/bin/ssh -p 82001 user@remotehost "mysqldump -u db_user -pSomePass mydb | gzip -c > /sql/mybackup.sql.gz" Example: % ssh user@host "echo remote" | echo local local user@host's password: % ssh user@host "echo remote | echo ...


5

Not that odd, you're piping the output of the ssh command within your shell; you should pipe it within the shell on the remote server: #!/bin/sh /usr/bin/ssh -p 82001 user@remotehost "mysqldump -u db_user -pSomePass mydb | gzip -c > /sql/mybackup.sql.gz" Also mind that you're not using bash, but sh. To use bash: #!/bin/bash /usr/bin/ssh -p 82001 ...


1

The task is quite simple using awk. Here's my example. I've created two files file-nm (for not-missing) and file-m(for missing), and moved directory for the files that we want to move. awk '/@<TRIPOS>BOND/ {getline; if ($0 == "@<TRIPOS>SUBSTRUCTURE" ) system("mv \""FILENAME"\" moved")}' file-nm file-m Here we find the @<TRIPOS>BOND ...


0

The problem is that your string is being interpreted twice, once by the local shell, and again by the remote shell which ssh is running for you. So you need to quote twice, using either of these: -p\''#8111*@uu('\' -p"'#8111*@uu('" Edit: If you are going to double-quote "" the entire command, you will have problems with passwords containing $. You need ...


0

Use double quotes twice, escaped and not escaped: -p"\"$MYPASSWORD\"" #!/bin/sh source pass.cre /usr/bin/ssh -p 91899 user@remoteHost 'mysqldump -u db_user -p"\"$MYPASSWORD\"" my_database | gzip -c > my_database.sql.gz' Or an other version /usr/bin/ssh -p 91899 user@remoteHost "mysqldump -u db_user -p\"'io#bc@14@9$#jf7AZlk99'\" my_database | gzip -c ...


4

You don't need popen - popen is what you use to start a process. We don't need to start another process. And you don't need to be piping things to/from STDIN/STDOUT ; /proc/meminfo follows the same rules as everything else in *nix. Everything is a file You can just open /proc/meminfo and process it like you would any other file. f = ...


7

[0-99] is the same as [0-9], [0-100] means [01]. [...] defines a character class, you can't use longer strings there. To solve your original question, you can use a loop: for i in {0..99} ; do grep "some string" file-"$i" > processed-"$i" done Or, if not all the possible input files exist, you can extract the suffix from the file name: for file ...


0

This single command should do the job, so it can simply be entered into your crontab: find /opt/abc/* -maxdepth 0 -mtime +2 ! -name '*.tar.gz' -exec tar czf {}.tar.gz {} \; -exec rm -rf {} \; I haven't tested it that thoroughly, but I am sure it won't accidentally delete stuff. It will, however, delete archives, if they have the same name as a directory ...


0

find /path/to/directory -mtime +2 -exec ls "{}" \; Is a useful snippet to list files over 2 days old, though it only counts full days, and there's an element of rounding that happens there, so using minutes with the -mmin option may work better. I've also seen people relpace the -exec with print0 and pipe the output to xargs, handles unusual filenames ...


0

You can use xargs -n 1 to only pipe a single file argument into the compress command. Be careful about spaces.


0

I haven't ever made such program but I find it on web. Try This Code I can paste it here, go here for the code.


0

In searching around I came across a better script and decided to try it, and it works: #!/bin/bash PATH=/usr/sbin:/usr/bin:/sbin:/bin if [[ ! "$(/usr/sbin/service mysql status)" =~ "start/running" ]] then echo "MySQL restarted" | mail -s "Email Subject" email@domain.com sudo service mysql start fi More info can be found here ...


0

In addition to A.B. answer, another solution: dpkg -L package-name Or in long format: dpkg --list-files package-name man dpkg -L, --listfiles package-name... List files installed to your system from package-name. So in your case run: dpkg -L maven and dpkg -L ant


0

The problem turned out to be the SysV script /etc/init.d/elasticsearch itself. In the script the PID_DIR variable is set as : PID_DIR=/var/run/elasticsearch but there is no such directory exists and there is command to create it in the script too. The NAME and PID_FILE are set as: NAME=elasticsearch PID_FILE="$PID_DIR/$NAME.pid" So when the ...


0

Using perl perl -MMIME::Base64 -ne 'printf "%s\n",decode_base64($_)' <<< "QWxhZGRpbjpvcGVuIHNlc2FtZQ==" Or the same with python python -m base64 -d <<< "QWxhZGRpbjpvcGVuIHNlc2FtZQ=="


0

As mentioned here EnvironmentVariables You can set system-wide environmental variables with three ways: /etc/environment /etc/profile /etc/profile.d/*.sh You could use for example /etc/profile. Execute this on your machine sudo echo "JAVA_HOME=/home/mockie/softwares/jdk1.8.0_45" >> /etc/profile


-2

hope this can help you. Just try to go into your home folder, press Ctrl+H (to see hidden folders) and there they should be. Cheers


0

I's switch to using grep's -q argument. This just exits with zero if it finds something. This allows you to use traditional exit-code logic like && or || to chain on actions. wget -qO- http://www.centennialcollege.ca/programs-courses/centres-institutes/applied-research-and-innovation/for-students/job-postings/ \ | grep -q "Game Developer" \ ...


1

Apart from excellent rename answers you have received already, you can use bash parameter expansion: for i in *.pdb.*; do mv -i "$i" "${i%%.pdb.*}_${i##*.}.pdb"; done The pattern ${i%%.pdb*} will get the file portion of name file.pdb.# ${i##*.} will get the digits after .pdb.


8

Via dpkg-query: dpkg-query -L maven dpkg-query -L ant or with a filter using grep dpkg-query -L maven | grep '^/usr/bin' sample output $ dpkg-query -L mc /. /usr /usr/share /usr/share/applications /usr/share/applications/mc.desktop /usr/share/doc /usr/share/doc/mc /usr/share/doc/mc/README.Debian /usr/share/doc/mc/NEWS.Debian.gz ...


1

Add to the /etc/profile file(For system wide change) or to ~/.bash_profile( local user) export CATALINA_HOME=/opt/apache-tomcat-8.0.23


-1

You find a very detailed answer here in the second reply. Limit the size of a directory by deleting old files to access cron you should type crontab -e


3

You can use capture groups and backreferences e.g. rename -vn -- 's/\.(pdb)\.(\d+)/_$2.$1/' *.pdb.* to match a literal period \. followed by (literal) string pdb, followed by a second period \. and then a sequence of one or more digits \d+, copying the string and digit sequence into numbered capture groups $1 and $2 respectively and then re-substituting ...


2

The strictest way possible, so that only filenames starting with file.pdb. followed by at least a digit will be renamed, using rename: rename -n 's/(file)(\.pdb)\.([0-9]+)/$1_$3$2/' * If the result is the expected one, remove the -n option: rename 's/(file)(\.pdb)\.([0-9]+)/$1_$3$2/' *


3

No problems here! The moonshadows@moonshadows-A740GM-M:~$ part is where you can enter your commands, so whenever it comes up, you know the previous process has finished. So you can safely exit the terminal and playonlinux will work fine.


2

If you have Zeitgeist daemon running on your system, it should save some helpful info to ~/.local/share/recently-used.xbel file. Zeitgeist monitors access to files on disk, so it should know your most recently played video file. Unfortunately the files are not sorted by file access, but the database contains that information too, so you can grep all data you ...


1

Update: To completely remove the launcher for the time your script execution, I'd disable the unity compiz plugin. We have such a script in Checkbox, that I'm pasting here for convenience: #!/usr/bin/env python3 # This file is part of Checkbox. # # Copyright 2014-2015 Canonical Ltd. # Written by: # Daniel Manrique <roadmr@ubuntu.com> # Sylvain ...


1

Do everything with awk as below: arrayvar=($(awk '/'"$vovar"'/,/}/ {gsub("'"$vovar"'"," "); gsub("}"," "); gsub("{"," ");gsub(","," ");all=all$0} END {print all}' temp1 ))


2

You could use this: var=( $(< input awk '/VARIABLES {/, /}/ {if ($0~/VARIABLES/||$0~/}/) next; else gsub(/[ ,]/, "", $0); print}') ) prints every record between a record matching VARIABLES { and a record matching }, removing every and , character However I'd rather use mapfile and a single fork in place of a double fork to store values into an ...


1

Using later versions of GNU grep (comes with Ubuntu) that has -z option: $ IFS=, arrayvar=( $(grep -Pzo '\s+VARIABLES\s+{\K[^}]+(?=})' temp1 | tr -d '[:space:]') ) $ echo "${arrayvar[0]}" a9EventCode $ echo "${arrayvar[1]}" a9ControllerNumber $ echo "${#arrayvar[@]}" 6 -z option makes grep to treat the lines of input text separated by ASCII NUL ...


4

In addition to http://askubuntu.com/a/643030/218015 you might can also define an alias inside your .bashrc for small, often used tasks. E.g. alias ll='ls -l' alias ls='ls --color=auto' will create you a "command" ll, which is doing ls -l and ls will be coloured after defining the alias. https://wiki.ubuntuusers.de/alias is having some more examples and a ...


13

What are my options? Is there another path with the same "run from anywhere" capability, which I can access without sudo, or another way to achieve something equivalent? How to do it? Create some dir in your home to hold your scripts normally named as bin as convention. mkdir ~/bin Now move your scripts to bin mv somescript ~/bin Now how to ...


2

Using comm, awk, users and /etc/passwd comm -23 <(awk -F: '/\/home/ && ($3 >= 1000) {print $1}' /etc/passwd | sort ) <(users | tr ' ' '\n' | sort | uniq) Breakdown % awk -F: '/\/home/ && ($3 >= 1000) {print $1}' /etc/passwd user1 user2 % users | tr ' ' '\n' | sort | uniq user1 % comm -23 <(awk -F: '/\/home/ && ...


2

You quoted the heredoc delimiter: sudo su<<'HERE' Variables in a heredoc are not expanded if the delimiter is quoted. From the docs: If any characters in word are quoted, the delimiter is the result of quote removal on word, and the lines in the here-document are not expanded. If word is unquoted, all lines of the here-document are ...


0

Latest bash-completion upstream moved and renamed things a bit. It's now: source /usr/share/bash-completion/completions/git __git_complete g __git_main Use this in recent versions of OSes (e.g. Fedora 22+) when you encounter: completion: function `_git' not found during completing.


2

For the specific file you show, if you just want the strings starting with copy, it is enough to do: var=( $(grep -o 'copy[^(]*' file) ) The you have: $ for((i=0;i<${#var[@]};i++)); do echo "${var[i]}"; done copyOperationPending copyInProgress copyOperationSuccess copyInvalidOperation copyInvalidProtocol copyInvalidSourceName copyInvalidDestName ...


6

Using grep: mapfile -t var < <(grep -Po '^\s+\K[^ ]+(?= ?\(\d+\),?$)' file.txt) grep -P will use PCRE (Perl Compatible Regular Expression) grep -o will print the matched portion of the line ^\s+\K will match the lines starting with whitespaces and \K will discard the match [^ ]+ will match our desired portion (?= *\(\d+\)) is the zero width ...


3

You can grep only the lines with the fields and use sed to remove everything after the opening parenthesis. The resulting list of words can be used directly to populate the array: var=($(grep input-file ' *[a-zA-Z]\+ \?([0-9]\+)' | sed 's/(.*//')) echo ${var[1]} The regular expression used in grep is: space + *: any number of spaces (including 0) ...



Top 50 recent answers are included