Search:

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

Page 1 of 10 1 2 3 4

Search: Search took 0.08 seconds.

  1. Re: rename multiple files in multiple directories using Bash scripting

    the script below sets up a test suite and runs the renaming procedure, according to the criteria


    #!/bin/bash

    # setting up testing data

    dataset=.
    mkdir -p "$dataset"/Nishi_{001..005}...
  2. Replies
    6
    Views
    576

    [SOLVED] Re: While statement returns me invalid syntax

    post the actual error message. Syntax error has nothing to do with the math. It's about the technical side of the code itself: missing parentheses, incorrect indentation and such.
  3. [SOLVED] Re: Python using the shift operators on Ubuntu 15.04

    i don't think python works differently in the domain of binary operators. I'd assume the job is farmed out to underlying C code.
    Maybe in that specific case you took advantage of the truthiness of...
  4. [SOLVED] Re: Python using the shift operators on Ubuntu 15.04

    https://docs.python.org/2/reference/expressions.html#operator-precedence

    >> is binds more strongly than &, so dta gets shifted first and then the result is binary-ANDed.





    &1 takes only...
  5. Replies
    5
    Views
    431

    Re: Problem with the "shebang" in ubuntu

    are you sure you put it in the very first line? If not, then your shebang is nothing but a comment (#)
  6. [SOLVED] Re: [Python numpy] Ambiguity with numerical type casting

    a quick research led me to this quick and dirty rule:

    python int is int64.
    if you mix unsigned types with it you get escalation to the int of higher width if possible to accomodate values outside...
  7. Replies
    1
    Views
    391

    Re: naming files same as folder name

    800_D1_TOC/800-d1-tocaree.xcf is supposed to become 800_D1_TOC/800_D1_TOC?

    assuming there is only 1 item in a relevant dir


    dirs=( 800_D1_TOC
    800_D1_ATA
    800_D1_MTN
    ...
  8. Replies
    2
    Views
    436

    Re: python repeat lists

    have you tried multiplying the shorter list by a number and then trimming it to specific length?
  9. Replies
    1
    Views
    367

    [SOLVED] Re: Trying to run an older python script

    try lowercasing the type name.


    >>> import numpy
    >>> numpy.Float32
    Traceback (most recent call last):
    File "<stdin>", line 1, in <module>
    AttributeError: 'module' object has no attribute...
  10. Re: Recursively searching and converting WMA files to MP3

    #!/bin/bash

    shopt -s globstar

    for f in **/*.[Ww][Mm][Aa]
    do
    path=${f%/*}
    filename=${f##*/}
    new=${filename// /_} # space -> underscore
    new=${new,,} # lowercase
  11. [SOLVED] Re: Shell: remove all lines containing specified pattern from all files in a folder

    a case of brainfart


    find ./folder -type f -exec sed -r -i '/pattern/d' {} +
  12. [SOLVED] Re: Shell: remove all lines containing specified pattern from all files in a folder

    what's wrong with loops?


    shopt -s globstar
    sed -r -i '/pattern/d' ./folder/**/*

    globstar for recursiveness, if the files are directly under folder then folder/* would cut it

    without...
  13. Replies
    3
    Views
    415

    Re: Bash shell reg expression for a number

    the first thing to mention is that there are 2 flavors of pattern matching in bash. Regular expressions used only with [[ =~ ]] and globs used everywhere else, less potent than regexes (then there...
  14. Replies
    3
    Views
    415

    Re: Bash shell reg expression for a number

    easy peasy

    case 1 - you are asking whether there is a digit (single at that) which makes anything with a single digit pass even, things like x0xoxoxoxoxox, which can be confirmed by printing out...
  15. Re: Using the subprocess module in Python scripting: checking command exit status?

    if you don't care about realtime output you can do something like this


    #!/usr/bin/env python3

    import subprocess as sub

    cmd = [ 'bash', '-c', '{ for i in {1..5}; do echo "$i"; echo "errrr...
  16. Replies
    5
    Views
    436

    Re: bash regex match

    well, both methods are logically equivalent, so whatever blows your hair back. Direct index is simpler though.

    and yes, my example dealt with capturing groups only, 0-th element was intentionally...
  17. Replies
    5
    Views
    436

    Re: bash regex match

    both [0] and [1]. It doesn't matter that they have the same value.


    $ [[ '123' =~ (1) ]] && printf '%s\n' "${BASH_REMATCH[@]}"
    1 total match
    1 capturing group...
  18. [SOLVED] Re: Bash: problem with single quote inside a double quote

    even more compact


    $ name=$( awk -F= '/^DISTRIB_ID/ { print tolower($2); }' /etc/*release )
    $ echo "$name"
    ubuntu

    1 command instead of 4.
  19. [SOLVED] Re: Bash: problem with single quote inside a double quote

    is there a reason why you are after NAME not ID?


    $ name=$( lsb_release -si )
    $ name=${name,,}
    $ echo "$name"
    ubuntu

    and if you really need to mangle etc/*release
  20. Re: bash: test -f doesn't accept quoted tilde from variable

    you can also leave the tilde outside the quotes for it to work, but the best solution imo would be to stop depending on shell unrolling the ~ shortcut and use $HOME that always works instead.
  21. Replies
    5
    Views
    436

    Re: bash regex match

    the problem is that bash doesn't really support regexes and its native globs are functionally a barebone subset of true regexes. There is also an extended variant of globs but they still fall short....
  22. Re: Call website's Javascript function from Bash script

    I don't think it will be THAT easy, i doubt selenium, no matter how awesome it might be, will expose remote code in foreign language as first class functions
    Python is secondary here, you do...
  23. Re: Call website's Javascript function from Bash script

    python + selenium using PhantomJS driver for a virtual webbrowser?




    #!/usr/bin/env python3

    from selenium import webdriver

    url = 'http://xxx.yyy.com'
  24. Replies
    4
    Views
    506

    [SOLVED] Re: help with bash for loop

    dir is indeed superfluous, i thought i will need it, but then i didn't and forgot to remove it



    I mean string operations on paths to get a rock solid transformation from src_path to dest_path...
  25. Replies
    4
    Views
    506

    [SOLVED] Re: help with bash for loop

    you go down 2 levels (*/*/) with cd but go up only 1 (..)
    That said personally i prefer to avoid cd-ing over the directory tree, i just transform paths


    #!/bin/bash

    dest=$HOME/test/crap/v0
    ...
Results 1 to 25 of 250
Page 1 of 10 1 2 3 4