Find the answer to your Linux question:

Search:

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

Page 1 of 20 1 2 3 4

Search: Search took 0.02 seconds.

  1. awk 'NR==1{s=$1; f=FILENAME; next} f != FILENAME...

    awk 'NR==1{s=$1; f=FILENAME; next}
    f != FILENAME {a=a?a FS s/n:s/n ; f=FILENAME; s=0}
    {s+=$1; n=FNR}
    END{print a, s/n}' a1.txt a2.txt a3.txt
  2. Replies
    2
    Views
    692

    Try this: awk -F "-" 'NF==2{$1=$1 "- -"}1'...

    Try this:

    awk -F "-" 'NF==2{$1=$1 "- -"}1' OFS= file
  3. Something like this: ...

    Something like this:


    defaultStorage="storage_02"

    percentage=$(awk -vx="$defaultStorage" '$1 ~ x{print $2}' file.dat)
  4. Replies
    4
    Views
    757

    storagename=$(awk ' NR==1{min=100;next} $3==0...

    storagename=$(awk '
    NR==1{min=100;next}
    $3==0 && int($2)<min{min=int($2); s=$1}
    END{print s}' file)

    The solution is also given in this forum:

    Get min from a column conditionally - The UNIX...
  5. Replies
    1
    Views
    737

    This should be sufficient IMHO: ls *.ele

    This should be sufficient IMHO:


    ls *.ele
  6. You can do something like this: awk -F"...

    You can do something like this:


    awk -F\" '{for(i=1;i<=NF;i+=2) {gsub(",", ";", $i)}}1' OFS= file.csv |
    awk -F\; '{ print $1;print $2;print $3;print $4;print $5}'
  7. Replies
    6
    Views
    2,106

    Change the IFS, replace your function try with: ...

    Change the IFS, replace your function try with:


    function try {
    OIFS=$IFS
    IFS=\n
    prt_status $1
    shift
    $* || quit
    IFS=$OIFS
  8. This question is also answered here: Trying to...

    This question is also answered here:

    Trying to combine upload and download totals from txt file by ip address - The UNIX and Linux Forums

    Regards
  9. Replies
    8
    Views
    1,231

    Works fine for me, this is the output I get with...

    Works fine for me, this is the output I get with this example, note that only the first line matches the pattern:


    $ cat file
    KERNEL=="tty[A-Z]*", NAME="%k", GROUP="uucp", MODE="0660"...
  10. Replies
    8
    Views
    1,231

    Try this: awk -v var='KERNEL=="tty[A-Z]*",...

    Try this:


    awk -v var='KERNEL=="tty[A-Z]*", NAME="%k", GROUP="uucp", MODE="0660"' '
    $0 == var{sub("MODE=\"0660\"","MODE=\"0666\"")}1' file > newfile
    mv newfile file
  11. Thread: #!/bin/sh

    by Franklin52
    Replies
    10
    Views
    4,551

    Better is to avoid the use of cat in a loop,...

    Better is to avoid the use of cat in a loop, don't go for the Useless Use of Cat Award:


    #!/bin/sh

    while read i
    do
    echo "$i"
    ...
    ...
  12. Try this: awk -F "- " '{print $2}' file

    Try this:

    awk -F "- " '{print $2}' file
  13. Replies
    5
    Views
    924

    Ok, here we go. awk '// && ++c==2 {$0=$0...

    Ok, here we go.


    awk '/<bb>/ && ++c==2 {$0=$0 RS "<here> </here>"}1'

    Explanation:


    /<bb>/ && ++c==2
  14. Replies
    5
    Views
    924

    If awk is allowed: awk '// && ++c==2...

    If awk is allowed:

    awk '/<bb>/ && ++c==2 {$0=$0 RS "<here> </here>"}1' file
  15. I should be careful with kill -9 but you can do...

    I should be careful with kill -9 but you can do something like:

    awk '{system("kill -9 " $0)}' file
  16. To run commands from a file: sh file from...

    To run commands from a file:


    sh file

    from the output of a command:

    command | sh
  17. Replies
    3
    Views
    1,100

    How about: grep -vf fileA.txt fileB.txt

    How about:


    grep -vf fileA.txt fileB.txt
  18. Replies
    5
    Views
    4,459

    Use single quotes with the date command: ...

    Use single quotes with the date command:


    $(/bin/date +'%F %T')" Some text" >> /home/me/foo.txt

    Or escape the % character:


    $(/bin/date +"\%F \%T")" Some text" >> /home/me/foo.txt
  19. Replies
    7
    Views
    1,981

    With a slightly modification: awk '/aaa/...

    With a slightly modification:


    awk '/aaa/ {if(s){print s}s="";f=1}f{s=s?s $1:$1 " "}' file
  20. Replies
    7
    Views
    1,981

    Judt replace $0 with $1: awk '/aaa/...

    Judt replace $0 with $1:


    awk '/aaa/ {if(s){print s}s="";f=1}f{s=s $1}' file
  21. Replies
    7
    Views
    1,981

    Should be something like: awk '/aaa/...

    Should be something like:

    awk '/aaa/ {if(s){print s}s="";f=1}f{s=s $0}' file
  22. Replies
    2
    Views
    787

    Try it with awk: awk...

    Try it with awk:


    awk '/FRED/{n=$2;print;next}{print n $0}' file
  23. Replies
    15
    Views
    1,942

    Try this: g++ --version | sed -n '/g++/...

    Try this:


    g++ --version | sed -n '/g++/ s/.*) \(.*\) \[.*/\1/p'

    or shorter with awk:


    g++ --version | awk '/g++/{print $4}'
  24. Replies
    1
    Views
    631

    Use code tags. Try this: awk -F "\t" '{ ...

    Use code tags.

    Try this:

    awk -F "\t" '{
    print "<row>"
    for(i=1;i<=NF;i++){
    print "<entry>" $i "</entry>"
    }
    print "</row>"
  25. Replies
    2
    Views
    914

    Try: sed -e...

    Try:

    sed -e "s|JAVA_OPTS=|JAVA_OPTS=<some_value>\\|"
Results 1 to 25 of 500
Page 1 of 20 1 2 3 4