Tag Info

Hot answers tagged

6

From the pkill manpage: The process name used for matching is limited to the 15 characters present in the output of /proc/pid/stat. Use the -f option to match against the complete command line, /proc/pid/cmdline. So try pkill -1 -f PirateRadio.py


6

This script allows you to enter a user that you are looking for. It will tell you whether or not the user is logged in or not and, if the user is logged in, from what location. read user This reads in the user name you entered `w | grep $user | cut -c19-30` The first part, w, prints out all logged in users accessing this machine. The grep $user filters ...


5

According to the man page for NetmorkManager, one of the events is dhcp4-change The DHCPv4 lease has changed (renewed, rebound, etc). I think you can simply change up) to dhcp4-change|up)


5

Here is a solution using awk: $ awk 'BEGIN{FS="\n";RS=""} {r[$1]=$0} END{n = asort(r); for (i=1;i<=n;i++){print r[i] "\n"}}' restaurants Restaurant: Five guys City: Atlanta State: Georgia Address: 123 Peachtree Rd Phone: 9234211 Restaurant: KFC City: NYC State: NY Address: 123 Madison Square Phone: 95311 Restaurant: McDonalds City: Miami State: ...


4

The simplest approach is to have your script continue only if apt-get exits correctly. For example: sudo apt-get install BadPackageName && ## Rest of the script goes here, it will only run ## if the previous command was succesful Alternatively, exit if any steps failed: sudo apt-get install BadPackageName || echo "Installation failed" && ...


4

After googling and trying I have found this work around. Install arp-scan if you are not already: sudo apt-get install arp-scan now run this command: sudo arp-scan -l This will search the whole network for duplicate IPs. When two Ips are the same a keyword(DUP) beside the ouput line will be shown and thus you can know the duplicates: % arp-scan -N ...


4

This should work for you: sed 's/"//g' files.csv | while IFS=, read orig new; do mv "$orig" "$new"; done Explanation: sed 's/"//g' files.csv : remove the quotes IFS=, : split the input on , while read orig new; do ... done : This will read each input line, split it on the value of $IFS (here a comma) and save the 1st field as $orig and the rest as ...


4

In the case =~ operator, just don't use quotes for the right operator. This is considered an extended regular expression so in this case the single quotes will be part from he regular expression. So, using single quotes, a string like '<img src="/thumbs/os_x_lynx-t1.jpg"' (which contain also single quotes around it) will be found. See Meaning of “=~” ...


4

Try with the find command: find /media/Przenośny/transcode/* -exec transcode -J stabilize --mplayer_probe -i {} \; I have to wait ~1min after this message to see the next file to be transcoded: [decoder.c] cancelling the import threads 0:01:24, ( 4, 9| 0, 0| 6, 1) Redirecting with >> is useless as all the logs go to stderr and are pretty verbose ...


3

You can try using rsync: rsync -av --include="*/" --include='*.png' --exclude='*' parent1 parent2 this creates directory parent2 and copies all files with .png extension with subdirectory structure to it. explanation -v verbose to see whats copied -a archive mode (copy subdirectories with same ownership, permissions etc.) --include '*/' ...


3

If you write [[ "$page" =~ '<img src="[^"]*\.jpg"' ]], then the right-hand side will be treated as an ordinary string, not a regex. See Bash regex statement. The solution is to escape all the special characters. otherwise you can use regex statement in a separate variable within single quotes '' like, var='<img src="[^"]*\.jpg' in these case you ...


3

The content of your desktop file should look like (see how to create a .desktop file using a text editor): [Desktop Entry] Version=1.0 Name=Test Comment=Test the terminal running a command inside it Exec=gnome-terminal -e "bash -c 'echo hello;$SHELL'" Icon=utilities-terminal Terminal=false Type=Application Categories=Application; Or: [Desktop ...


3

By default, for bash, the command history are stored in ~/.bash_history file. As an alternative you can do this: #!/bin/bash date >> ~/myhistory.log cat ~/.bash_history >> ~/myhistory.log echo -n "" > ~/.bash_history This will append to ~/myhistory.log (if the file is already there, else create a new file and write to it) the date when the ...


2

Here's a simpler version of your script, (keeping the humor intact :) ): #!/bin/bash ## The && means that the script will run the next command only if this one ## succeeds, in other words, only if the string `version 1.0` is found. bleachbit --version | grep -q 'version 1.0' && echo "$(tput setaf 2)The elves have verified the BleachBit ...


2

The easiest way is if you can get there from the filename. For instance, if the selected filename is /mnt/home/$USER/shell_logs/20140326.log, you could get to another file in the same directory with a different extension, or another file in another directory pretty easily. Let's first look at stripping the extension off: ...


2

Since this is my script (rewritten a bit by Webupd8's Andrew), this should work : uninstalling Popcorn Time : sudo rm -r /opt/Popcorn-Time sudo rm /usr/share/pixmaps/popcorntime.png sudo rm /usr/share/applications/popcorn-time.desktop sudo rm /usr/bin/popcorn-time remove the NodeJS sudo add-apt-repository -r ppa:chris-lea/node.js sudo apt-get remove ...


2

I don't know if there is a way to run things after entering your password as you request and I doubt there will be since that is handled by the desktop environment (probably the screensaver daemon). However, it should work perfectly well if you add the right scripts to /etc/pm/sleep.d. Since you have not shown the scripts you've tried, my guess is that you ...


2

A bash script uses the same syntax as the standard command line in Ubuntu. If you can launch your game with moon-buggy (ie, it's installed in the path), it'll work in your script. If you've just downloaded the file (to, for example, ~/Downloads/moon-buggy), you'll probably need to make it executable with chmod +x ~/Downloads/moon-buggy and in your script, ...


1

Since ipaddr.py is library for inspecting and manipulating IP address, the first thing you'll want to do is create some objects. You can use ipaddr to create objects from strings, integers or other ipaddr objects. Check the following wiki page for examples: http://code.google.com/p/ipaddr-py/wiki/Using3144 Depending on your needs, installing the ...


1

This sounds very much like a band aid and an XY Problem and you would be better off figuring out the core problem. Still, these commands will do what you need. I have written it as a shell function, not an alias, but just add these lines to your ~/.bashrc file: fix_config(){ ## Change current working directory to the directory where .config file is ...


1

Here is a verbose solution as a python script. Not literally what you were asking for, but yet a solution: #!/usr/bin/python3 import os # change the lines below to the correct paths path_to_configfile = "path_to_configfile" # the real one in /etc/dhcp/dhclient.conf path_toconfigfile_a = "path_toconfigfile_a" path_toconfigfile_b = "path_toconfigfile_b" # ...


1

That's a coincidence, it's your system changing the current cpu frequency. Check with this command in a terminal: watch -n 0 "lscpu | grep 'MHz'" You will see (when waiting a bit) that the system's cpu frequency is switching. You can also get your current cpu frequency with this command: cat /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_cur_freq And ...


1

I do not know what exactly is "content that I believe is appropriate". However, if you can run the script through terminal all you have to do is create a script with: #!/bin/bash cd /path/to/folder command-you-would-run-in-terminal Make the script executable. Then in your .desktop file, launch the script instead of your command directly. Example ...


1

This is the answer: #! /bin/bash #clear _temp="/tmp/answer.$$" STRING="" COUNTER=0 for i in $(ls /mnt/home/$USER/shell_logs/*.log ); do let COUNTER=COUNTER+1 STRING=$(echo $STRING $i \"$COUNTER\" \"OFF\" ) done dialog --backtitle "Radiolist" --radiolist "test" 0 0 0 $STRING 2>$_temp result=`cat $_temp` clear cat $result


1

Stuff in /etc/profile.d is probably sourced by your window manager when you log in, and that probably uses /bin/sh, so target a POSIX shell, not bash, for scripts to be added there. Note that [[ is not found in the scripts that are in there now. So, choose [ ... ] over [[ ... ]] use funcname() { ... } without the function keyword dash is a POSIX (only) ...


1

I put this short script together that seems to work for me! This also include a bit of my own brand of elvish humor. I am using this code in a larger script so I can copy and paste this conditional anywhere I need it. #!/bin/bash # Check BleachBit Version and install if necessary if [ "$(bleachbit --version | grep -c 'version 1.0')" = "0" ]; then ...


1

wget --content-disposition URL Update: This is supposed to be the command but according to the man page it is experimental. It may not work. You can use wget --no-clobber "URL". What this does is skips any files that you already have. Though I am bit confused. If you already have the URL to the exact filename, how could the version be different? I would ...


1

Here is the script you want. Enjoy! #!/bin/bash # License: GPL-2 # by desgua # 2014 April 10 # # This script is provided "as is" without warranty of any kind, either expressed or implied, including, but not limited to, the implied warranties of merchantability, fitness for a particular purpose, or non-infringement. # # Always backup your files # ...


1

You can use: bash -c "$(curl -kL http://serverip/script.sh)" This will run the script on the local machine. See also man bash to understand why I used -c option. Also double quotes are very important in this case. Also, as @terdon said in his comment, sudo curl is pointless. If If the script needs local sudo permissions, you need to use sudo in front of ...



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