Search Results

Search found 4482 results on 180 pages for 'mr bash'.

Page 17/180 | < Previous Page | 13 14 15 16 17 18 19 20 21 22 23 24  | Next Page >

  • Does bash have a hook that is run before executing a command?

    - by Gilles
    In bash, can I arrange for a function to be executed just before running a command? There is $PROMPT_COMMAND, which is executed before showing a prompt, i.e., just after running a command. Bash's $PROMPT_COMMAND is analogous to zsh's precmd function; so what I'm looking for is a bash equivalent to zsh's preexec. Example applications: set your terminal title to the command being executed; automatically add time before every command.

    Read the article

  • Bash child proccess PID - how do you get it?

    - by Jason Tan
    Can any one tell me how to get the PID of a command executed in bash. E.g. I have a bash script that runs imapsync. When the script is killed the imapsync process does not always get killed, so I'd like to be able to identify the PID of imapsync programatically from my script, so that I can kill the imapsync process myself in a signal handler. So how do I programatically get the PID of a child process from a parent bash script? Thanks Folks

    Read the article

  • When to use Bash, when Python/Perl/Ruby? [closed]

    - by futlib
    What's your rationale for when to write a Bash script and when to use a more powerful scripting language (Python, Perl, Ruby, ...)? I'm finding that very simple scripts are nicer with Bash, but many of those get quite fancy over time, and it never seems like a good idea to rewrite the whole thing. That's why I'm leaning towards always using Python for all scripting. But since Bash seems to be the the lingua franca of Linux scripting, is that something a responsible system administrator would do?

    Read the article

  • How can I upgrade bash to >= 4.1 on CentOS 5.5?

    - by Agvorth
    I have a CentOS 5.5 VPS server. I want to use RVM. According to the console output when I run the RVM installer, RVM requires bash = 4.1. I just ran yum update. My bash version is now 3.2.25. If I understand how yum works, that means that 3.2.25 is sort of the version of bash that "belongs with" my CentOS version, and it's the latest version I can get using yum. (Right? Or am I wrong about this?) How can I get that on my CentOS 5.5 system? To clarify, I understand that I can just download the source and install, but I'm hesitant to break out of yum's version management system. Is there a way to upgrade bash without disrupting yum?

    Read the article

  • how to copy the results from a grep command to the bash clipboard?

    - by avilella
    If I type something in a Linux bash terminal with no X, and then use Ctrl+u, whatever I typed is stored in the bash "clipboard" (for lack of a better term), and I can type it again doing Ctrl+y. How can I copy the results from a grep command on a text file to such bash clipboard? For example, if I have an INSTALL file like this: ./installprocedure --do-some-long-and-complicated-operation-on-dir dir1 How can I copy the content of a grep command so that it's available doing Ctrl+y? For example: copy content to bash clipboard "grep installprocedure INSTALL" Ctrl+y ./installprocedure --do-some-long-and-complicated-operation-on-dir dir1 #cursor available here

    Read the article

  • How to get the cursor position in bash ?

    - by Julien Nicoulaud
    In a bash script, I want to get the cursor column in a variable. It looks like using the ANSI escape code {ESC}[6n is the only way to get it, for example the following way: # Query the cursor position echo -en '\033[6n' # Read it to a variable read -d R CURCOL # Extract the column from the variable CURCOL="${CURCOL##*;}" # We have the column in the variable echo $CURCOL Unfortunately, this prints characters to the standard output and I want to do it silently. Besides, this is not very portable... Is there a pure-bash way to achieve this ?

    Read the article

  • Regular expression in BASH

    - by Ryan
    Hello everyone, I was hoping someone could answer my quick question as I am going nuts! I have recently started learning regular expressions in my Java programming however am a little confused how to get certain features to work correctly directly in BASH. For example, the following code is not working as I think it should. echo 2222 | grep '2\{2\}' I am expecting it to return: 22 I have tried variations of it including: echo 2222 | grep '2{2}' echo 2222 | grep -P '2\{2\}' echo 2222 | grep -E '2\{2\}' However I am completely out of ideas. I'm sure this is a simple parameter / syntax fix and would love some help! P.S I've done tons of googling and every reference I find does not work in BASH; regex's can run on so many different platforms and engines =/

    Read the article

  • Renaming and Moving Files in Bash

    - by KT
    HI, I'm completely new to Bash and StackOverflow. I need to move a set of files (all contained in the same folder) to a target folder where files with the same name could already exist. In case a specific file exists, I need to rename the file before moving it, by appending for example an incremental integer to the file name. The extensions should be preserved. The file names could contain dots in the middle. Originally, I was thinking about comparing the two folders to have a list of the existing files (I did this with "comm"), but then I got a bit stuck. I think I'm just trying to do things in the most complicated possible way. Any hint to do this in the "bash way"?

    Read the article

  • Inserting text to a file with Sed within Bash Script

    - by neversaint
    I tried to insert a text to the first line of a file using sed. I do this inside a bash script. But why it hangs at the line of sed execution? #! /bin/bash # Command to execute # ./mybashcode.sh test.nbq nbqfile=$1 nbqbase=$(basename $nbqfile nbq) taglistfiletemp="${nbqbase}taglist_temp" taglistfile="${nbqbase}taglist" ./myccode $nbqfile | sort | uniq -c | awk '{print $2}' > $taglistfiletemp noftags=$(wc -l $taglistfiletemp | awk '{print $1}') echo $noftags # We want to append output of noftags # to the first line of taglistfile sed '1i\ $noftags' > $taglistfile # why it hangs here # the content of taglistfile is NIL

    Read the article

  • bash bcmath functions

    - by Gordon
    I have two functions for GNU bc in a Bash script. BC_CEIL="define ceil(x) { if (x>0) { if (x%1>0) return x+(1-(x%1)) else return x } else return -1*floor(-1*x) }\n" BC_FLOOR="define floor(x) { if (x>0) return x-(x%1) else return -1*ceil(-1*x) }\n" echo -e "scale=2"$BC_CEIL$BC_FLOOR"ceil(2.5)" | bc Both functions work fine in interactive bc. bc does not seem to allow multiple functions on one line separated by ; though, so I have to echo -n | bc with newlines at the end of each function. The above output is 2.5, not the expected 3.0 that I get if I type it into bc -i myself. It seems that bash calls bc for each line of echo output, rather than echo'ing it all to a single instance. Is there any workaround for this?

    Read the article

  • bash : recursive listing of all files problem

    - by Michael Mao
    Run a recursive listing of all the files in /var/log and redirect standard output to a file called lsout.txt in your home directory. Complete this question WITHOUT leaving your home directory. An: ls -R /var/log/ /home/bqiu/lsout.txt I reckon the above bash command is not correct. This is what I've got so far: $ ls -1R .: cal.sh cokemachine.sh dir sort test.sh ./dir: afile.txt file subdir ./dir/subdir: $ ls -R | sed s/^.*://g cal.sh cokemachine.sh dir sort test.sh afile.txt file subdir But this still leaves all directory/sub-directory names (dir and subdir), plus a couple of empty newlines How could I get the correct result without using Perl or awk? Preferably using only basic bash commands(this is just because Perl and awk is out of assessment scope)

    Read the article

  • bash script to delete old deployments

    - by benjwarner
    I have a directory where our deployments go. A deployment (which is itself a directory) is named in the format: <application-name>_<date> e.g. trader-gui_20091102 There are multiple applications deployed to this same parent directory, so the contents of the parent directory might look something like this: trader-gui_20091106 trader-gui_20091102 trader-gui_20091010 simulator_20091106 simulator_20091102 simulator_20090910 simulator_20090820 I want to write a bash script to clean out all deployments except for the most current of each application. (The most current denoted by the date in the name of the deployment). So running the bash script on the above parent directory would leave: trader-gui_20091106 simulator_20091106 Any help would be appreciated.

    Read the article

  • using bash: write bit representation of integer to file

    - by theseion
    Hullo First, I want to use bash for this and the script should run on as many systems as possible (I don't know if the target system will have python or whatever installed). Here's the problem: I have a file with binary data and I need to replace a few bytes in a certain position. I've come up with the following to direct bash to the offset and show me that it found the place I want: dd bs=1 if=file iseek=24 conv=block cbs=2 | hexdump Now, to use "file" as the output: echo anInteger | dd bs=1 of=hextest.txt oseek=24 conv=block cbs=2 This seems to work just fine, I can review the changes made in a hex editor. Problem is, "anInteger" will be written as the ASCII representation of that integer (which makes sense) but I need to write the binary representation. How do I tell the command to convert the input to binary (possibly from a hex)?

    Read the article

  • Adding line with text between pattern and next occurence of the same pattern in bash

    - by kasper
    I am writing a bash script that modifies a file that looks like this: --- usr1 --- data data data data data data data data data data data data --- usr2 --- data data data data data data data data --- usr3 --- data data data data --- endline --- One question is: How to add next user line --- usrn --- after last user data lines? Second one is: How to delete specific user data lines (data lines and --- userx ---) i.e. I would like to delete usr2 with all his data set. It must work on bash 2.05 :) and I think it will use awk or sed, but I'm not sure.

    Read the article

  • bash: flushing stdin (standard input)

    - by rahul
    I have a bash script that gets some input as stdin. After processing, I copy a file using "-i" (interactive). However, this never gets executed since (I guess) standard input has not been flushed. To simplify with an example: #!/bin/bash while read line do echo $line done # the next line does not execute read -p "y/n" x echo "got $x" Place this in t.sh, and execute with: ls | ./t.sh The read is not executed. I need to flush stdin before the read. How could it do this?

    Read the article

< Previous Page | 13 14 15 16 17 18 19 20 21 22 23 24  | Next Page >