Search Results

Search found 5228 results on 210 pages for 'bash alias'.

Page 24/210 | < Previous Page | 20 21 22 23 24 25 26 27 28 29 30 31  | Next Page >

  • Append or modify keys in conf files using sed/bash one-liner

    - by Jeff
    I often have to modify files such as sysctl.conf, and I'm familiar with using sed to replace existing values. Is there a way to append the new key/value pair to the file if sed wasn't able to replace it? For instance, using this example: modify config file using bash script sed -c -i "s/\($TARGET_KEY *= *\).*/\1$REPLACEMENT_VALUE/" $CONFIG_FILE How could I add the $TARGET_KEY = $REPLACEMENT_VALUE new line to $CONFIG_FILE using the same sed expression with slight changes? And on a related topic, how can I force creation of $CONFIG_FILE if it didn't exist?

    Read the article

  • Float conditional in bash

    - by Werner
    Hi, in bash I need to compare two float numbers, one which I define in the script and the other read as paramter, for that I do: if [[ $aff -gt 0 ]] then a=b echo "xxx "$aff #echo $CX $CY $CZ $aff fi but I get the error: [[: -309.585300: syntax error: invalid arithmetic operator (error token is ".585300") What is wrong? Thanks

    Read the article

  • Bash Read Array from External File

    - by jmituzas
    I have setup a Bash menu script that also requires user input. These inputs are wrote (appended to) a text file named var.txt like so: input[0]='192.0.0.1' input[1]='username' input[2]='example.com' input[3]='/home/newuser' Now what I am trying to accomplish is to be able to read from var.txt from a script kinda like this: useradd var.txt/${input[1]} now I know that wont work just using it for an example. Thanks in Advance, Joe

    Read the article

  • kill a process in bash

    - by wyatt
    How do I kill a process which is running in bash - for example, suppose I open a file: $ gedit file.txt is there any way within the command prompt to close it? This example is fairly trivial, since I could just close the window, but it seems to come up a bit, particularly when I mistype commands. Also is there any way to escape an executable which is running? This probably has the same solution, but I thought I'd ask anyway. Thanks

    Read the article

  • bash shell date parsing, start with specifc date and loop through each day in month

    - by Joe Stein
    Hi, I need to create a bash shell script starting with a day and then loop through each subsequent day formatting that output as %Y_%m_d I figure i can submit a start day and then another param for the number of days. My issue/question is how to set a DATE (that is not now) and then add a day. so my input would be 2010_04_01 6 my output would be 2010_04_01 2010_04_02 2010_04_03 2010_04_04 2010_04_05 2010_04_06 Thanks

    Read the article

  • Bash command that prints a message on stderr

    - by Salman A
    I want to know if there is a built-in BASH command that prints some text on stderr, just like the echo command that prints text on stdout. I don't want to use temporary io-redirection. I use a built-in command to generate an error on stderr such as ls --asdf (ls: unrecognized option '--asdf') but I want something neater,

    Read the article

  • Removing spaces from columns of a CSV file in bash

    - by vikas ramnani
    I have a CSV file in which every column contains unnecessary spaces(or tabs) after the actual value. I want to create a new CSV file removing all the spaces using bash. For example One line in input CSV file value1 ;value2 ;value3 ;value4 same line in output csv file should be value1;value2;value3;value4 I tried using awk to trim each column but it didnt work. Can anyone please help me on this ? Thanks in advance :)

    Read the article

  • Convert numbers to enumeration of strings in bash

    - by User1
    Using bash, I have a list of strings that I want to use to replace an int. Here's an example: day1=Monday day2=Tuesday day3=Wednesday day4=Thursday day5=Friday day6=Saturday day7=Sunday If I have an int, $dow, to represent the day of the week, how do I print the actual string? I tried this: echo ${day`echo $dow`} but get error of "bad substitution". How do I make this work? Note: I can change the $day variables to a list or something.

    Read the article

  • Printf example in bash does not create a newline

    - by WolfHumble
    Working with printf in a bash script, adding no spaces after "\n" does not create a newline, whereas adding a space creates a newline, e. g.: No space after "\n" NewLine=`printf "\n"` echo -e "Firstline${NewLine}Lastline" Result: FirstlineLastline Space after "\n " NewLine=`printf "\n "` echo -e "Firstline${NewLine}Lastline" Result: Firstline Lastline Question: Why doesn't 1. create the following result: Firstline Lastline I know that this specific issue could have been worked around using other techniques, but I want to focus on why 1. does not work.

    Read the article

  • sum up value from textfile - bash

    - by user3493435
    I am trying to sum up the values in a textfile try.txt firstNumber,1 secondNumber,2 I tried with this script #!/bin/bash while IFS, read -r -a array; do printf "%s %s\n" "${array[0]} ${array[1]}" for n in "${array[1]}"; do ((total += n)) echo "total =" $total done done < try.txt and I landed up with this output firstNumber 1 total = 1 secondNumber 2 total = 3 expected output firstNumber 1 secondNumber 2 total = 3 Thanks in advance

    Read the article

  • SubSonic Alias/Where Clause

    - by JohnBob
    Hey, I want to convert the following SQL Query to a SubSonic Query. SELECT [dbo].[tbl_Agency].[ParentCompanyID] FROM [dbo].[tbl_Agency] WHERE REPLACE(PhoneNumber, ' ', '') LIKE REPLACE('%9481 1111%', ' ', '') I thought I would do it like below, but I just can't get it to produce valid SQL. //SubSonic string agencyPhoneNumber = "9481 1111"; SubSonic.SqlQuery subQueryagencyPhoneNumber = new SubSonic.Select(Agency.ParentCompanyIDColumn.ColumnName); subQueryagencyPhoneNumber.From(Agency.Schema.TableName); //WHERE subQueryagencyPhoneNumber.Where("REPLACE(" + Agency.PhoneNumberColumn.ColumnName + ", ' ', '')").Like("%" + agencyPhoneNumber + "%"); Does anyone out there know how to fix this - I'm using SubSonic 2.2. I feel like I'm taking crazy pills here - this should be straightforward, right? Cheers, JohnBob

    Read the article

  • Conecting bash script with a txt file

    - by cathy
    I have a txt file with 100+ lines called page1.txt; odd lines are urls and even lines are url names. I have a bash file already created that checks urls for completion. Except right now, the process is really manual because I have to modify the bash every time I need to check a url. So I need to connect the bash to the txt using the variable url. $url should get all the odd lines from page1.txt and check if the link is complete or not. Also, how would I write a variable called name that derives from the url the 7 digits? bash file manually: url=http://www.-------------/-/8200233/1/ name=8200233 lynx -dump $url > $name.txt I would prefer if the bash file could add "Complete/In-Complete " at the beginning of every even line in the page1.txt file but a new text file could be also created to keep track of the Completes/In-completes.

    Read the article

  • sql query with alias name

    - by Ranjana
    i have a table with this columns--- Or orgid ispaid validity noofthingstoTake 1 yes 2010-06-05 20 2 yes 2010-06-09 7 i have used this query(to join two more tableS): select distinct B.RequirementID,A.OrganizationID from Organization A,RequirementsDetailsforOrganization B,validityorgdet F where A.OrganizationID=B.OrganizationID and F.orgid=A.OrganizationID and F.ispaid=1 and F.validity>=GETDATE() and F.noofthingstoTake> ?? but i dont know how to check the (noofthingstaken) over here. it should not exceed 20. im passing this query from my code behind page to the Sql. how to get the query excute to check it should not exceed the noofthingstaken pls help me out....????

    Read the article

  • Bash Shell Scripting Errors: ./myDemo: 56: Syntax error: Unterminated quoted string [EDITED]

    - by ???
    Could someone take a look at this code and find out what's wrong with it? #!/bin/sh while : do echo " Select one of the following options:" echo " d or D) Display today's date and time" echo " l or L) List the contents of the present working directory" echo " w or W) See who is logged in" echo " p or P) Print the present working directory" echo " a or A) List the contents of a specified directory" echo " b or B) Create a backup copy of an ordinary file" echo " q or Q) Quit this program" echo " Enter your option and hit <Enter>: \c" read option case "$option" in d|D) date ;; l|L) ls $PWD ;; w|w) who ;; p|P) pwd ;; a|A) echo "Please specify the directory and hit <Enter>: \c" read directory if [ "$directory = "q" -o "Q" ] then exit 0 fi while [ ! -d "$directory" ] do echo "Usage: "$directory" must be a directory." echo "Re-enter the directory and hit <Enter>: \c" read directory if [ "$directory" = "q" -o "Q" ] then exit 0 fi done printf ls "$directory" ;; b|B) echo "Please specify the ordinary file for backup and hit <Enter>: \c" read file if [ "$file" = "q" -o "Q" ] then exit 0 fi while [ ! -f "$file" ] do echo "Usage: \"$file\" must be an ordinary file." echo "Re-enter the ordinary file for backup and hit <Enter>: \c" read file if [ "$file" = "q" -o "Q" ] then exit 0 fi done cp "$file" "$file.bkup" ;; q|Q) exit 0 ;; esac echo done exit 0 There are some syntax errors that I can't figure out. However I should note that on this unix system echo -e doesn't work (don't ask me why I don't know and I don't have any sort of permissions to change it and even if I wouldn't be allowed to) Bash Shell Scripting Error: "./myDemo ./myDemo: line 62: syntax error near unexpected token done' ./myDemo: line 62: " [Edited] EDIT: I fixed the while statement error, however now when I run the script some things still aren't working correctly. It seems that in the b|B) switch statement cp $file $file.bkup doesn't actually copy the file to file.bkup ? In the a|A) switch statement ls "$directory" doesn't print the directory listing for the user to see ? #!/bin/bash while $TRUE do echo " Select one of the following options:" echo " d or D) Display today's date and time" echo " l or L) List the contents of the present working directory" echo " w or W) See who is logged in" echo " p or P) Print the present working directory" echo " a or A) List the contents of a specified directory" echo " b or B) Create a backup copy of an ordinary file" echo " q or Q) Quit this program" echo " Enter your option and hit <Enter>: \c" read option case "$option" in d|D) date ;; l|L) ls pwd ;; w|w) who ;; p|P) pwd ;; a|A) echo "Please specify the directory and hit <Enter>: \c" read directory if [ ! -d "$directory" ] then while [ ! -d "$directory" ] do echo "Usage: "$directory" must be a directory." echo "Specify the directory and hit <Enter>: \c" read directory if [ "$directory" = "q" -o "Q" ] then exit 0 elif [ -d "$directory" ] then ls "$directory" else continue fi done fi ;; b|B) echo "Specify the ordinary file for backup and hit <Enter>: \c" read file if [ ! -f "$file" ] then while [ ! -f "$file" ] do echo "Usage: "$file" must be an ordinary file." echo "Specify the ordinary file for backup and hit <Enter>: \c" read file if [ "$file" = "q" -o "Q" ] then exit 0 elif [ -f "$file" ] then cp $file $file.bkup fi done fi ;; q|Q) exit 0 ;; esac echo done exit 0 Another thing... is there an editor that I can use to auto-parse code? I.e something similar to NetBeans?

    Read the article

  • How to create a bash function with variable parameters/arguments to grep several keywords/tags

    - by CornSmith
    I'm using the :!grep "tag1" filename | grep "tag2" filename | grep -n "tag3 or more" filename command in vim to search for my code snippets based on their tags (a simple comment at the top of a snippet) in one big file. I use snippets to remember tricky things. This is painful to write out each time. I'd like to make an alias, or function to do something like this: :!greptag tag1 tag2 ... tag39 And it should search the current doc and return the lines with all the tags on them. Vim is set to interactive shell mode so that it can parse my bashrc for aliases/functions. set shellcmdflag=-ic How can I construct a function that allows for variable arguments like this in bash?

    Read the article

< Previous Page | 20 21 22 23 24 25 26 27 28 29 30 31  | Next Page >