New answers tagged

0

You can put quotes around the commands you are aliasing. You can even put them around the alias, too. 'llg'='ll | grep' Newlines are also a problem. Widows-saved .bashrc file caused errors in Ubuntu virtual machine: command not found I ran dos2unix .bashrc to convert the line endings, and then everything worked.


0

I cannot get the hang of commenting. I can't post the code as it's too long, I can't upload it. I can't eveng get a new line on it, so I have to answer my own question #!/bin/bash cd ~/Desktop file="$(zenity --title "3D Converter: Select a File to convert" --file-selection --file-filter=""*.ctm" "*.ply" "*.stl" "*.3ds" "*.dae" "*.obj" "*.lwo" "*....


1

You can't kill a Zombie, its already dead. It is just talking an entry in the process table before the parent process do wait(2) to read it's exit status. On a different note, to kill the parent process of any process (including Zombie), you can easily use a combination of commands ps and kill: ps -p <pid> -o ppid= will give use the PPID (Parent ...


2

Here's one way: #!/bin/bash mydate=$(date '+%Y-%m-%d %H:%M:%S') myip=$(curl http://checkip.amazonaws.com?newline -s) printf '%s %s\n' "$mydate" "$myip" >> /home/test_a5gh/Pub_IP.txt FYI, you don't need sudo to chmod files you own in your own home directory.


0

For some very odd reason , ctmconv doesn't recognize quoted variables as one entity if their contents contain spaces. (Which may also be a worthwhile to report this behavior as a bug to the developers). I suggest you use any text-editing tool , such as sed or awk to insert backslash before space. For instance, something like this. $ echo "with space" | sed ...


1

Not really one single command, but why make it more complicated than necessary? find -type f -name ".*" -delete; rm *~ The first command removes all files starting with . and the second one all ending with ~


1

Bash makes a difference between single quotes '...' and double quotes "...". Single quotes cause the enclosed text to be taken literally while double quotes allow various interpretations of the string like variable expansion. You must use double quotes if you have $x-like Bash variables in your string which you want to be expanded. Additionally, directly ...


0

Since you are using linux it's very easy, in linux a packet is represented by structure sk_buff. You can use netfilter framework with pre-routing hook,to mangle packet by using it's protocol and destnation port number. See the netfilter framework documentation .


0

in terminal type "chmod +x filepath". This will convert your sh file to an executable file that will run when you open it


1

You asked "How do I concatenate them?" - and the answer is, quite simply, with cat: NAME cat - concatenate files and print on the standard output SYNOPSIS cat [OPTION]... [FILE]... DESCRIPTION Concatenate FILE(s), or standard input, to standard output. Note in particular that its inputs can include standard input, not just files. ...


1

As the STDOUT stream is block buffered by default (when not going to terminal) by python, you need to make the stream unbuffered (or line buffered). python provides a way to make the streams unbuffered, here is the Pythonic way: python -u foo.py So, your whole command line becomes: python -u foo.py | ~/timestamp.sh >> ~/logs/foo.log From man ...


1

The root cause is your process, here python, is using libc stdout where the output is line buffered when output to a terminal but block buffered when output to something else, like a pipe here. You can fix the issue either in the python code by explicitly flushing the buffer after each log output: sys.stdout.flush() or by controlling how buffering will ...


0

I resolve my problem using gksu nautilus. If someone have the same issue you can fixed: Ctrl+Alt+F1 gksu nautilus sudo nautilus /root edit the bash.bashrc


0

If you have access to that file over nautilus, or whatever you are using, just double-click your .bashrc and an editor will open. You may need to hit CTRL+H first, to unhide hidden files. This is the default Ubuntu .bashrc, found on GitHub. Just replace yours with this one. Then you can readd you changes and see what causes the error. # ~/.bashrc: ...


2

Click in Ubuntu icon (the first bottom in side menu). Write gedit Open Text Editor clicking in its icon. Click in Open. In the list, write: ~/.bashrc Enter Clean your failing .bashrc file. Save and you can open terminal again.


0

Managed to get the script running properly using netcat's nc's exit status, while running it without -v option. Anyway, it seems that netcat's netcat's output doesn't get piped into grep. I suppose it might be caused by some sort of forking. UPDATE: As terdon mentioned in a comment to his answer, part of output from nc / netcat is printed to stderr, part ...


0

Serg's script seemed to work at first. However after some time, the percentage was being evaluated incorrectly especially after coming back from hibernation. It may have been some issues with qdbus but the brightness level won't just change. So, I decided to hardcode the brightness level using the value from max_brightness file. Here's my /usr/local/bin/auto-...


1

Run the following: mv /home/folder1/test123 /home/folder1/test456


2

If you want to append successive outputs of a command substitution to an array in bash, you can use a syntax like arr+=( "$(command args)" ) For example, give files with $ grep -H 'versionName' thing* thing1:versionName: foo thing2:versionName: bar thing3:versionName: baz thing4:versionName: boo then $ for f in thing*; do version+=( "$(grep '...


4

The problem has nothing to do with nc or netcat or any of their ilk. You are running two commands here, nc and grep, but only redirecting the output of grep. What you want to do is: nc -zv 1.2.3.4 55 &>/dev/null That, of course, would be pointless since if there's no output, you can't grep. That's what grep's -q flag is for: -q, --quiet, --...


1

edit your ~/.zshrc source /etc/zsh_command_not_found and run source ~/.zshrc


1

I'm using another solution: echo '$var = <string> 1.11 </string>' | awk -F'> | <' '{print $1,$3}' What I did was defining > and < as delimiters and printing certain fields between the delimiters.


0

Bash has also its own regular expressions. However, they are not so powerful as in sed. The following code does the magic without calling external programs: var="<string> 1.11 </string>" first=${var#<*>} second=${first%<*>} #echo $first echo $second I tried to do it in one step too, but didn't succeed because bash regular ...


0

You're at the GRUB prompt. You should have some options available. Those options are what systems you can boot your computer into. If only Ubuntu is listed, try booting into it, and using the disk-manager to check if your Windows partition still exists or not. If you did delete the Windows partition, and have not installed anything since then, there's a ...


2

Intro The script below allows remembering brightness levels depending on the power source used by a laptop. It defaults to 50% on battery, 90% on AC. Overview of options and usage source_monitor.sh [-a INT] [-b INT] [-v] [-h] -a set initial brightness on AC adapter -b set initial brightness on batter -v enable verbose output -h prints this help text ...


-2

Your problem is that, by the time you open a terminal, the i flag is no longer set in '$-'. Replace: # If not running interactively, don't do anything case $- in *i*) ;; *) return;; esac with: # If not running interactively, remember case $- in *i*) IsInteractive=1;; *) IsInteractive=0;; esac


0

Cuttlefish is a tool that helps automate settings changes based on events such us as plugging and unplugging the power supply


0

Try changing the startup entry to this: x-terminal-emulator -e "bash -c '~/Desktop/Elaborati/script1.sh'" However, if you don't want the terminal to close once the script has finished executing, use this instead: x-terminal-emulator -e "bash -c '~/Desktop/Elaborati/script1.sh;echo Press any key to close this window...;read -sn1 null'" Why 'bash -c'? To ...


0

The following is a bash script which wraps up the perl process suggested in this answer Example: /tmp/it console: enabled:false Then run the following: $ search_and_replace_on_line_of_file.sh false true 2 /tmp/it and the file now contains /tmp/it console: enabled:true search_and_replace_on_line_of_file.sh function show_help() { IT=$(CAT &...


2

You could use sed for string manipulation: echo '$var = <string> 1.11 </string>' | sed -r 's/<string>(.*)<\/string>/\1/g' returns $var = 1.11 Explanation of the sed construct: sed -r # call sed with regex-option (-r) 's/ # begin of regex (s means "replace, / is the seperator) ...


1

Perhaps the easiest method is to simple run the following command from the current directory: ls > mycurrent There are many options available to the ls command to tailor the output to your specific needs.


0

Well, I too faced the same problem. I wanted to execute the .sh file and it opened with Gedit on CentOS 7. So here is what I did: I navigated to the path of the .sh file I wanted to execute. I opened the terminal. And I simply dragged and dropped the on the terminal window and it automatically took that file along with the path as input. Hit Enter and you ...


2

A bash script must start with a shebang, to let the launching process know it's a script that should be run in the bash shell. So the first line of your script should be #!/bin/bash. This is a good convention to get into, it is how bash scripts should be written. Your script currently works when you run bash /home/backupscript.sh because you're already ...


3

Make sure your script has set the execute flag when executing it directly or use bash as interpreter with the script as input. To use bash as interpreter change the line to 0 4 24-31 * 4 bash /home/backupscript.sh To set the execute flag for the script use: chmod +x /home/backupscript.sh


3

Your script is using a lot of CPU resources because it runs continuously, which is inefficient. To avoid this, add a call to sleep, which means that it will only do it's work once every 5 seconds, which is a lot more efficient. You can probably extend this to even more, like 60 seconds, depending on how frequent / accurate it needs to be. Here's what it ...


2

You can create new bash files simply with creating a new file and making it executable. e.g. touch simplebash.sh now add the shebang to the file so it knows in which shell you actually want to run the script. You can do this with this simple echo forward or just simple edit the file with an editor echo "#!/bin/bash" > simplebash.sh Change the ...


3

From the p7zip manual: -ao (Overwrite mode) switch Specifies the overwrite mode during extraction, to overwrite files already present on disk. Syntax -ao[a | s | t | u ] Switch Description -aoa Overwrite All existing files without prompt. -aos Skip extracting of existing files. -aou aUto rename extracting file (for ...


1

set is often used to set the positional parameters ($1, $2, $3, etc., which are usually provided as arguments to the script). By using these parameters, we can get a simple way to count things via the $# variable, which stores the number of set positional parameters. ? is a wildcard matching any single character, so ??? matches any combination of three ...


5

What does the root and # mean in the second command line tag? It means you edit the system as "root". That is 1 more level up than from "sudo" and 1 more up from your normal users activities ... what does this mode allow you to do ... and (almost) all permissions checks are neglected. So if want you can seriously destroy your system with a single ...


0

can you try by placing below at top of script SAVEIFS=$IFS IFS=$(echo -en "\n\b") and IFS=$SAVEIFS in bottom of script


1

Just to add another way to do it: emacs -Q --batch -eval '(princ (base64-encode-string (read-string ": ")))'


16

There are two shells involved here: The calling shell, the interactive shell from which you are running this The non-login, non-interactive shell, spawned by bash -c Now, the problem is, within double quotes the variables are expanded to their respective values, this is true for any shell. So, as you have used double quotes, the variable expansion, $v, ...


0

I found this link and it fixed my problem along with what Ziazis originally suggested Ziazis' suggestion: sudo chown user:usergroup -R /home/user Once that was implemented, I stopped getting the Unable to open universal variable file '/home/username/.config/fish/fishd.Dlorah': Permission denied error, but the PAM authentication error still came up. ...


2

Please see this question that was posted on the Unix & Linux Stack Exchange. The first sentence says: Under Linux, at always warns you that it will execute the specified commands with /bin/sh, rather than your favorite shell. You cannot suppress this message, it's hard-coded in the source code. It also suggests a workaround: The command you ...


0

Late into the game but here is a very different solution using plain bash and cp: you can use a global file specification while having some files ignored. Assume the directory contains the files: $ ls * listed1 listed2 listed3 listed4 unlisted1 unlisted2 unlisted3 Using the GLOBIGNORE variable: $ export GLOBIGNORE='unlisted*' $ ls * listed1 ...


2

Probably your .bashrc or .profile is messedup. Your gedit will not start if it is not in path and since your path is empty it is not in the path. You should first establish a good enough path. export PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin And then you should be able to start gedit. Alternativelly you could just run gedit with ...


2

When you open a terminal, you are in your home directory: $HOME. The Downloads folder is a subdirectory of your $HOME, so it's $HOME/Downloads. Therefore, to run a script in that directory you need to either: Move into that directory first and then run it: cd Downloads bash canopy-1.7.2-rh5-64.sh Use the full path bash Downloads/canopy-1.7.2-rh5-64.sh


12

As @Videonauth suggested, you can use apt-get install php7.* but that will install all packages whose names contain php7. To install those whose names starts with php7, use apt-get install '^php7. *. To instal only those on your list, you can use brace expansion. The format is almost what you already tried: braces but a comma-separated list: $ echo foo{a,b,...


0

I had the exact same problem last year for backups that took several hours! You can try Keep.Awake https://launchpad.net/keep.awake It can monitor CPU load, network traffic and user activity for minimum thresholds. I still haven't gotten around to creating a snap or deb for it. However temporarily you can download the program from Launchpad here The ...



Top 50 recent answers are included