Search Results

Search found 3730 results on 150 pages for 'bash'.

Page 5/150 | < Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • Differences between fish and bash to pass commandline arguments to alias functions?

    - by NES
    From the answers to my other question here i learned about the possibility to pass commandline arguments to a alias function in Bash. In Fish i can edit an alias by editing the file config.fish in ~/.config/fish directory and adding a line like this alias lsp='ls -ah --color=always | less -R;' and it works perfectly. This should be the equivalent to editing ~/.bash_aliases in bash But when i try to setup an alias function to pass arguments like this alias lsp='_(){ ls -ah --color=always $* | less -R; }; _' it doesn't work for fish? Are there any differences between fish and bash in the way to setup an alias to pass commandline arguments that prevent this second alias from working with fish instead of bash?

    Read the article

  • Bash History not containing all history and blank after reboot, how to resolve?

    - by TryTryAgain
    I've recently upgraded from 13.04 to 13.10 and realized my terminal bash history is not surviving reboots. cat ~/.bash_history gave me a permissions denied error. I, possibly unnecessarily or wrongly, issued a chmod 777 ~/.bash_history to see if that would help...and although I could then cat and read some contents it contained not much of anything as far as history. I also tried sudo rm ~/.bash_history after reading bash history not being preserved Strangely, after doing that, I typed a few test commands, ls, ls -lah ... and upon pressing the up arrow to go back through history it contained those two commands as well as the odd history from some far off time in the past but very few results and not the hundreds of commands I typed earlier in the day. Is there a new place bash history is stored? How can removing ~/.bash_history not get rid of the commands that are somehow lingering? I am not certain, but I believe my root bash history is acting normal. My user bash history is what's causing me trouble. Any help and guidance in tracking down and solving this problem is appreciated.

    Read the article

  • Is there a difference between "." and "source" in bash, after all?

    - by ysap
    I was looking for the difference between the "." and "source" builtin commands and a few sources (e.g., in this discussion, and the bash manpage) suggest that these are just the same. However, following a problem with environment variables, I conducted a test. I created a file testenv.sh that contains: #!/bin/bash echo $MY_VAR In the command prompt, I performed the following: > chmod +x testenv.sh > MY_VAR=12345 > ./testenv.sh > source testenv.sh 12345 > MY_VAR=12345 ./testenv.sh 12345 [note that the 1st form returned an empty string] So, this little experiment suggests that there is a difference after all, where for the "source" command, the child environment inherits all the variables from the parent one, where for the "." it does not. Am I missing something, or is this is an undocumented/deprecated feature of bash? [ GNU bash, version 4.1.5(1)-release (x86_64-pc-linux-gnu) ]

    Read the article

  • Why some user functions don't get recognised by bash?

    - by strapakowsky
    I can define a function like: myfunction () { ls -R "$1" ; } And then myfunction . just works. But if I do echo "myfunction ." | sh echo "myfunction ." | bash the messages are: sh: myfunction: not found bash: line 1: myfunction: command not found Why? And how can I call a function that comes from a string if not by piping it to sh or bash? I know there is this command source, but I am confused of when I should use source and when sh or bash. Also, I cannot pipe through source. To add to confusion, there is this command . that seems to have nothing to do with the "." that means "current directory".

    Read the article

  • Delete until previous punctuation mark in Bash

    - by hekevintran
    In Bash, Ctrl + W will erase the last word. Bash considers words to be delimited by spaces. This means that if the cursor is at the end of the string "cd /dir1/dir2/dir3" and you hit Ctrl + W you will be left with "cd ". Is there a Bash shortcut (custom defined is okay) that will leave me with "cd /dir1/dir2/"?

    Read the article

  • Simple bash scripting

    - by Richard Cotton
    I'm trying to get to grips with bash scripting via cygwin. My script is about as simple as it gets. I change the directory to the root of my C drive, and print the new location. #!/usr/bin/bash cd /cygdrive/c pwd is saved in the file chdir.sh in my home directory. I then call ./chdir.sh from the bash prompt. This results in the error : No such file or directorygdrive/c /cygdrive/c/Documents and Settings/rcotton I definitely have a C drive, and the command cd /cygdrive/c works when I call it directly from the bash prompt. I realise that this problem is likely stupidly simple; please can you tell me what I'm doing wrong.

    Read the article

  • Accessing the output of a Bash pipe with 'read'

    - by Karthik
    I'm trying to pipe some data from a Bash pipe into a Bash variable using the read command, like this: $ echo "Alexander the Grape" | read quot $ echo $quot $ But quot is empty. Some Googling revealed that this is not a bug; it's an intended feature of Bash. (Section E5 in the FAQ.) But when I tried the same thing in zsh, it worked. (Ditto for ksh.) Is there any way to make this work in Bash? I really don't want to have to type: $ quot=$(echo "Alexander the Grape") Especially for long commands.

    Read the article

  • Call 'script' command and exit it from within a bash script

    - by William Jamieson
    I'm using the linux 'script' command http://www.linuxcommand.org/man_pages/script1.html to log all input and output in an interactive bash script. At the moment I have to call the script command, then run my bash script, then exit. I want to run the script and exit commands from within the actual bash script itself. How can I do this? I've tried script -a but that doesn't work for interactive scripts. Any assistance would be greatly appreciated.

    Read the article

  • Bash script 'while read' loop causes 'broken pipe' error when run with GNU Parallel

    - by Joe White
    According to the GNU Parallel mailing list this is not a GNU Parallel-specific problem. They suggested that I post my problem here. The error I'm getting is a "broken pipe" error, but I feel I should first explain the context of my problem and what causes this error. It happens when trying to use any bash script containing a 'while read' loop in GNU Parallel. I have a basic bash script like this: #!/bin/bash # linkcheck.sh while read domain do host "$domain" done Assume that I want to pipe in a large list (250mb say). cat urllist | ./linkcheck.sh Running host command on 250mb worth of URLs is rather slow. To speed things up I want to break up the input into chunks before piping it and then run multiple jobs in parallel. GNU Parallel is capable of doing this. cat urllist | parallel --pipe -j0 parallel ./linkcheck.sh {} {} is substituted by the contents of urllist line-by-line. Assume that my systems default setup is capable of running 500ish jobs per instance of parallel. To get round this limitation we can parallelize Parallel itself: cat urllist | parallel -j10 --pipe parallel -j0 ./linkcheck.sh {} This will run 5000'ish jobs. It will also, sadly, cause the error "broken pipe" (bash FAQ). Yet the script starts to work if I remove the while read loop and take input directly from whatever is fed into {} e.g., #!/bin/bash # linkchecker.sh domain="$1" host "$1" Why will it not work with a while read loop? Is it safe to just turn off the SIGPIPE signal to stop the "broken pipe" message, or will that have side effects such as data corruption? Thanks for reading.

    Read the article

  • How to pass bash script arguments to a subshell

    - by Ralf Holly
    I have a wrapper script that does some work and then passes the original parameters on to another tool: #!/bin/bash # ... other_tool -a -b "$@" This works fine, unless the "other tool" is run in a subshell: #!/bin/bash # ... bash -c "other_tool -a -b $@" If I call my wrapper script like this: wrapper.sh -x "blah blup" then, only the first orginal argument (-x) is handed to "other_tool". In reality, I do not create a subshell, but pass the original arguments to a shell on an Android phone, which shouldn't make any difference: #!/bin/bash # ... adb sh -c "other_tool -a -b $@"

    Read the article

  • How to interrupt stuck bash tab completion?

    - by codeape
    Case: A Windows share mounted using samba over a flaky VPN connection (sometimes very slow, sometimes it drops) When doing tab-completion on filenames, my bash shell can freeze up if the VPN is slow or dropped when I am attempting the tab completion. Example: $ cp myfile.zip /mnt/winbox-c/Progr<tab> key pressed here Is there a bash key I can press to get bash out of its hung state when something like this happens?

    Read the article

  • Strange difference in bash behavior across systems

    - by pinkie_d_pie_0228
    I have two systems, an Ubuntu computer and an Android tablet. I have built and configured bash for Android to be used in adb, so it's the same version as my Ubuntu bash, and they use mostly the same bashrc and configuration, and the same exact options set by shopt. However, there is a slight difference in that the Android bash behaves as I expect when I I try to tab-complete something using a variable in it, but the Ubuntu bash doesn't. #Android ls $HOME/loc<tab> => ls $HOME/local #As expected Basically, the variable is taken into account when completing. But then #Ubuntu ls $HOME/loc<tab> => ls \$HOME/loc #Undesired behavior. The list of options is as follows, and is the same in both builds of bash. autocd:checkwinsize:cmdhist:expand_aliases:extglob:extquote:force_fignore:histappend:interactive_comments:progcomp:promptvars:sourcepath What can be making the Ubuntu version escape the $ instead of using it for completion as in the Android build? What can I do to make both work the same way? Any help will be greatly appreciated.

    Read the article

  • How to make BASH try and autocomplete on Enter

    - by swatso33
    I've noticed that for many of the commands I use in bash I have actually learned how many letters of the command I must type before I can press [TAB] to have bash successfully autocomplete the command. For example when opening chromium I dont usually type the whole command but instead type $ chrom[TAB][ENTER] and bash successfully autocompletes the command to chromium before I hit the [ENTER] key. Is there a way to make autocomplete work without having to hit [TAB]? My general thinking is that if I type $ chrom[ENTER] bash could check and see that chrom isnt a valid command, but it would make sense to autocomplete it to chromium since that is the only command that starts with chrom

    Read the article

  • Sourcing a script file in bash before starting an executable

    - by abigagli
    Hi, I'm trying to write a bash script that "wraps" whatever the user wants to invoke (and its parameters) sourcing a fixed file just before actually invoking it. To clarify: I have a "ConfigureMyEnvironment.bash" script that must be sourced before starting certain executables, so I'd like to have a "LaunchInMyEnvironment.bash" script that you can use as in: LaunchInMyEnvironment <whatever_executable_i_want_to_wrap> arg0 arg1 arg2 I tried the following LaunchInMyEnvironment.bash: #!/usr/bin/bash launchee="$@" if [ -e ConfigureMyEnvironment.bash ]; then source ConfigureMyEnvironment.bash; fi exec "$launchee" where I have to use the "launchee" variable to save the $@ var because after executing source, $@ becomes empty. Anyway, this doesn't work and fails as follows: myhost $ LaunchInMyEnvironment my_executable -h myhost $ /home/me/LaunchInMyEnvironment.bash: line 7: /home/bin/my_executable -h: No such file or directory myhost $ /home/me/LaunchInMyEnvironment.bash: line 7: exec: /home/bin/my_executable -h: cannot execute: No such file or directory That is, it seems like the "-h" parameter is being seen as part of the executable filename and not as a parameter... But it doesn't really make sense to me. I tried also to use $* instead of $@, but with no better outcoume. What I'm doing wrong? Andrea.

    Read the article

  • bash tips needed for understanding how to escape characters in command-line

    - by Jesper Rønn-Jensen
    My knowledge of commandline bash is missing on a particular area: I constantly forget how to properly escape characters. Today I wanted to echo this string into a file: #!/bin/env bash python -m SimpleHTTPServer echo "#!/bin/env bash\npython -m SimpleHTTPServer" server.sh && chmod +x server.sh -bash: !/bin/env: event not found That's right: Remember to escape ! or bash will think it's a special bash event command. But I can't get the escaping right! \! yields \! in the echoed string, and so does \\!. Furthermore, \n will not translate to a line break. Do you have some general tips that makes it easier for me to understand escaping rules? To be very precise, I'll accept an answer which tells me which characters I should escape on the bash command line? Including how to correctly output newline and exclamation mark in my example.

    Read the article

  • Bash script "read" not pausing for user input when executed from SSH shell

    - by Aaron Hancock
    I'm new to Bash scripting, so please be gentle. I'm connected to a Ubuntu server via SSH (PuTTY) and when I run this command, I expect the bash script that downloads and executes to allow user input and then echo that input. It seems to just write out the echo label for the input request and terminate. wget -O - https://raw.github.com/aaronhancock/pub/master/bash/readtest.sh | bash Any clue what I might be doing wrong? UPDATE: This bash command does exactly what I wanted bash <(wget -q -O - https://raw.github.com/aaronhancock/pub/master/bash/readtest.sh)

    Read the article

  • Why does my $LD_LIBRARY_PATH get unset when using screen with bash?

    - by UltraNurd
    This is related to http://superuser.com/questions/27376/why-does-my-ld-library-path-get-unset-launching-terminal, but a different set of symptoms. First, /usr/bin/screen is setuid as per the other question. Second, the default shell on this system is /bin/tcsh for various historical reasons, and we're not allowed to chsh to /bin/bash, so I typically run bash manually immediately after login. Third, I almost always use screen, but I want ctrl-a ctrl-c in screen to create a new bash "tab", so I always invoke bash first. That is: {~} $ echo $SHELL /bin/tcsh {~} $ bash [~] echo $SHELL /bin/bash [~] screen -U [~] ...and when reconnecting: {~} $ echo $SHELL /bin/tcsh {~} $ screen -dUr [~] echo $SHELL /bin/bash [~] However, my $LD_LIBRARY_PATH is there in tcsh, there in bash, but empty once I run screen; it is still present if I just run screen from tcsh, but then I get new tcsh "tabs" when I use ctrl-a ctrl-c in screen. Any ideas?

    Read the article

  • pattern matching in Bash

    - by Tim
    Hi, Here is an example to get different parts of a filename bash-3.2$ pathandfile=/tmp/ff.txt bash-3.2$ filename=$(basename $pathandfile) bash-3.2$ echo $filename ff.txt bash-3.2$ echo ${filename##*.} txt bash-3.2$ echo ${filename%.*} ff I was wondering what does ## and % mean in the patterns. How is the patten matching working? Thanks and regards!

    Read the article

  • Bash wonkyness on Ubuntu versus RHEL

    - by d34dh0r53
    Fellow faulters, I'm playing around with a one liner that I've developed on a RHEL 5.4 box and I have it working perfectly: TOTAL_RAM=`free | grep Mem: | awk '{ print $2 }'`; \ ps axo rss,comm,pid | awk -v total_ram=$TOTAL_RAM \ '{ proc_list[$2] += $1; } END { for (proc in proc_list) \ { proc_pct = (proc_list[proc]/total_ram)*100; printf("%d\t%s\t%0.2f%\n", proc_list[proc],proc,proc_pct); }}' \ | sort -n | tail -n 10 Which outputs something like the following on my RHEL box: 3736 logmon 0.01% 4156 EvMgrC 0.01% 4692 hald 0.01% 5020 ntpd 0.02% 6252 sshd 0.02% 7784 cvd 0.02% 9224 snmpd 0.03% 13068 dsm_sa_datamgr3 0.04% 23320 dsm_om_connsvc3 0.07% 4249864 mysqld 12.90% However on my Ubuntu 9.04 slice I get this: awk: run time error: not enough arguments passed to printf("%d %s %0.2f% ") FILENAME="-" FNR=104 NR=104 33248 console-kit-dae 3.17 I think it has to be bash that is borking something, but I'm really not doing anything that should be that bash specific. The RHEL box is running: # yum info bash | grep -e Version -e Release Version : 3.2 Release : 24.el5 And the Ubuntu box: # apt-cache show bash | grep -e Version Version: 3.2-5ubuntu1 I haven't dug into this super deeply, and thought I'd ping my fellow johnnys to see if you've ever run across this before. /bow

    Read the article

  • Multi-select menu in bash script

    - by am2605
    I'm a bash newbie but I would like to create a script in which I'd like to allow the user to select multiple options from a list of options. Essentially what I would like is something similar to the example below: #!/bin/bash OPTIONS="Hello Quit" select opt in $OPTIONS; do if [ "$opt" = "Quit" ]; then echo done exit elif [ "$opt" = "Hello" ]; then echo Hello World else clear echo bad option fi done (sourced from http://www.faqs.org/docs/Linux-HOWTO/Bash-Prog-Intro-HOWTO.html#ss9.1) However my script would have more options, and I'd like to allow multiples to be selected. So somethig like this: 1) Option 1 2) Option 2 3) Option 3 4) Option 4 5) Done Having feedback on the ones they have selected would also be great, eg plus signs next to ones they ahve already selected. Eg if you select "1" I'd like to page to clear and reprint: 1) Option 1 + 2) Option 2 3) Option 3 4) Option 4 5) Done Then if you select "3": 1) Option 1 + 2) Option 2 3) Option 3 + 4) Option 4 5) Done Also, if they again selected (1) I'd like it to "deselect" the option: 1) Option 1 2) Option 2 3) Option 3 + 4) Option 4 5) Done And finally when Done is pressed I'd like a list of the ones that were selected to be displayed before the program exits, eg if the current state is: 1) Option 1 2) Option 2 + 3) Option 3 + 4) Option 4 + 5) Done Pressing 5 should print: Option 2, Option 3, Option 4 and the script terminate. So my question - is this possible in bash, and if so is anyone able to provide a code sample? Any advice would be much appreciated.

    Read the article

  • passing on command line options in bash

    - by bryan
    I have a question. I have a script, a kind of long script written in bash aprox. 370 lines. That has several functions and in those functions the user has to enter information which is then stored in files. ( This is suppose to represent a MySQL database, with the functions INSERT, UPDATE, SELECT, SELECT where x=y.) I created this myself in bash, now the only thing that rests me is that I need to be able to pass arguments on the command line to the script, that will do the same as the script does. I know that bash has positional parameters such as $1 $2 $3 $* $@ $0 ( refers to the name of the script) etc. I know how I can use these parameters in a simple if function. This is not enough for my script. I basicly need to do the same thing that the script does, but then from the command line. I have been struggling with this for a couple of days now and I cannot think of a way to get it to work. Maybe someone here can help me with this? If you want to have the script. That can be possible, but I don't think I can paste it in here... EDIT: Link to script, http://pastebin.com/Hd5VsDv2 Note, I am a beginner in bash scripting. EDIT: This is in reply to Answer 1. As I said I hope I can just replace the if [ "$1" = "one" ] ; then echo "found one" to if [ "$1" = "one" ] ; then echo SELECT where SELECT is the function I previously had in my script(above) http://pastebin.com/VFMkBL6g LINK to testing script

    Read the article

  • Case insensitive bash auto-complete

    - by Vitaly Polonetsky
    Is there a way to make the file/dir auto-complete in bash case insensitive? For example I would like to write: /opt/ibm/whatever/test [TAB] And bash will auto-complete it to: /opt/IBM/Whatever/TESTfile Or at least only the last part of test to TESTfile. I know that filesystems are case-sensitive, I just don't want to remember which parts are UPPER-case, I want auto-complete to fix the path for me. And if I have both TESTfile and testfile, just show me both of them like bash does today with auto-complete conflicts.

    Read the article

  • Bash script to keep last x number of files and delete the rest

    - by Brady
    I have this bash script which nicely backs up my database on a cron schedule: #!/bin/sh PT_MYSQLDUMPPATH=/usr/bin PT_HOMEPATH=/home/philosop PT_TOOLPATH=$PT_HOMEPATH/philosophy-tools PT_MYSQLBACKUPPATH=$PT_TOOLPATH/mysql-backups PT_MYSQLUSER=********* PT_MYSQLPASSWORD="********" PT_MYSQLDATABASE=********* PT_BACKUPDATETIME=`date +%s` PT_BACKUPFILENAME=mysqlbackup_$PT_BACKUPDATETIME.sql.gz PT_FILESTOKEEP=14 $PT_MYSQLDUMPPATH/mysqldump -u$PT_MYSQLUSER -p$PT_MYSQLPASSWORD --opt $PT_MYSQLDATABASE | gzip -c > $PT_MYSQLBACKUPPATH/$PT_BACKUPFILENAME Problem with this is that it will keep dumping the backups in the folder and not clean up old files. This is where the variable PT_FILESTOKEEP comes in. Whatever number this is set to thats the amount of backups I want to keep. All backups are time stamped so by ordering them by name DESC will give you the latest first. Can anyone please help me with the rest of the BASH script to add the clean up of files? My knowledge of BASH is lacking and I'm unable to piece together the code to do the rest.

    Read the article

  • Is it possible to run bash builtin from non bash script?

    - by tig
    Is it possible to run for example history -w for underlying bash shell from ruby script? Or better is it possible to run builtin command for bash shell knowing only its pid? The only way I found is to trap signal like trap "history -w" SIGUSR1 and then send signal to process, but I am not sure that it is a good practice and USR1 is not used by bash, also this way I can execute max 2 commands (USR1 and USR2). And I have to define trap before using it. I am on Mac so there is not SIGRTMIN..SIGRTMAX.

    Read the article

< Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >