Search:

Type: Posts; User: cbillson; Keyword(s):

Page 1 of 3 1 2 3

Search: Search took 0.00 seconds.

  1. Replies
    4
    Views
    264

    Re: Help with SED and variables containing &

    Thanks for this, i'm sorry, I should have expanded on what i'm doing, i'm using a for loop and $myvar is coming from a text file
  2. Replies
    4
    Views
    264

    Re: Help with SED and variables containing &

    I've found a way via experimentation, though appreciate thoughts if this is a good way or if there are better




    VAR1="$(echo "$myvar" | sed 's/&/\\&/g')"

    sed -i "s/agent-name/$VAR1/g"...
  3. Replies
    4
    Views
    264

    Help with SED and variables containing &

    I hope someone can help as this one is driving me up the wall and i'm not sure how to fix it.

    myfile:-

    ----
    agent-name
    ------
  4. Re: reading a file and taking each line as a new variable

    Sorry, at the time of creating the post i was trying to keep the question simple, the data is more like this:




    Name = bob
    address = 123 any st
    address1 = anytone
    postcode = ab123cd
    phone1...
  5. Re: reading a file and taking each line as a new variable

    Cheers, the source option works spot on, though I'm concerned about the next commend "hackish"



    This option works, however it fails if the data has spaces.

    ie
  6. reading a file and taking each line as a new variable

    I have a file, its format is fixed as follows:



    data1 = 12345
    data2 = 54321
    data3 = 98765
    data4 = 56789
  7. Replies
    0
    Views
    304

    system hardening

    Hi, wonder if anyone could assist, I'm concerned I'm likely to lock myself out :D

    I have an Ubuntu box which mostly runs a single application, which runs under root. a number of folders and logs...
  8. Re: building an array from a non-fixed string

    i'm not sure that will work for what i hope to achieve. However, thank-you very much for that command, it could come in extremely useful..

    i'm thinking use SED in the way you describe to add a...
  9. building an array from a non-fixed string

    if i had a file that contained lines such as:


    name=bob smith address=123 any st town=london phone=01234567890 notes=some notes about bob smith of any length containing potentially any data

    ...
  10. getting data from a file where you only know a partial match and dont want the full l

    lets say i have a file that has:


    name=123 data=blah
    name=124 data=blah
    name=125 data=blah
    name=126 data=blah
    name=127 data=blah

    i need to get "123" into a variable, so i could use a for...
  11. Re: Using a variable in the exho of another variable

    Thanks.. having a play now

    for (( i=1; i<${#array[@]}; i++ )); do echo "array[$i]: ${array[$i]}"; done

    i get that i = start of array, as mine was specified as array[1] array[2] array[3] and it...
  12. Re: Using a variable in the exho of another variable

    ok, another question.. using the array with a for loop.

    normally a for loop will repeat until it runs out of things to repeat on, like if you're using a file (lines) or a directory (files).

    how...
  13. Re: Using a variable in the exho of another variable

    you sir are a star..

    thank-you to everyone who advised, much appreciated
  14. Replies
    3
    Views
    430

    incrementing a variable

    In Dos i could do the following: i need help translating this into linux shell.


    test1=bob
    test2=joe
    test3=ken
    test4=none

    set var=0
  15. Using a variable in the exho of another variable

    Hi, i know how to do this in DOS, and i'm hoping its possible in linux.


    file1=bob
    file2=joe
    file3=ken

    var=1

    Output needs to be echo $file1
  16. Replies
    10
    Views
    606

    Re: diff - changes from one file only

    I managed to get a variation of this to do what i needed, i'm unsure why what i did first off was different to this, but i was missing something :S

    Thanks to everyone who stuck with me and...
  17. Replies
    10
    Views
    606

    Re: diff - changes from one file only

    second command, should that have some reference to /var/log/syslog ?
  18. Replies
    10
    Views
    606

    Re: diff - changes from one file only

    if you take a copy of syslog at 1pm (old) and a copy at 2pm (new) and compare using diff, you will get an output of all the additions to the file between 1pm and 2pm.

    The 'old' file remains...
  19. Replies
    10
    Views
    606

    Re: diff - changes from one file only

    hmm, fallen at about the second hurdle..

    echo test > test

    tail -1 test | grep test

    returns: test

    tail -1 /var/log/syslog | grep /var/log/syslog
  20. Replies
    10
    Views
    606

    Re: diff - changes from one file only

    Mostly because i didnt know how to do what you describe :oops::oops:

    however i find what you put really interesting and i'll have a stab at getting it working :)
  21. Replies
    10
    Views
    606

    diff - changes from one file only

    Me again! i'm using diff to compare two files, output the differences to a third file and work from that.

    file1 = original file (syslog in this case)
    file2 = last view of original file

    My...
  22. Re: SED from a shell script - driving me up the wall!!!

    ahh, thank-you very much - you learn something new every day..
  23. SED from a shell script - driving me up the wall!!!

    why does this work

    sed -e 's/.*Jun 19//' myfile

    And this not

    mmm=Jun
    dd=19
    sed -e 's/.*$mmm $dd//' myfile
  24. Re: Getting creative with SED - removing string and x digits after

    Thanks for the info, makes total sense, and could prove very useful in some other things i'm trying to do - cheers :)
  25. Getting creative with SED - removing string and x digits after

    Hi, HELP!

    i have a file i'd like to shrink in size a little, and as the date appears twice, i've decided thats a good start.

    the file appears as:

    < Jun 17 00:00:00 - some data

    I'm using...
Results 1 to 25 of 74
Page 1 of 3 1 2 3