[SOLVED] How To Break Up Long Statement In Bash Script?

Hello Everyone,
  If have the following If statement in a script:
if [[ $1 =~ ^[A-Fa-f0-9]{4,4}\:[A-Fa-f0-9]{4,4}\:[A-Fa-f0-9]{4,4}\:[A-Fa-f0-9]{4,4}\:[A-Fa-f0-9]{4,4}\:[A-Fa-f0-9]{4,4}\:[A-Fa-f0-9]{4,4}\:[A-Fa-f0-9]{4,4}$ ]]; then
Is there any way to break this statement into multiple lines? I tried entering a \ after a portion of the statement and then pressing Enter to add a newline but it did not work.
thriftyb
Last edited by thriftyb (2015-04-03 21:44:13)

Alad wrote:
if grep -xP '(([A-Fa-f0-9]{4}):){7}(?2)' <<< "$1"; then
http://www.regular-expressions.info/subroutine.html
That works too. I didn't know that grep could be used that way. Thanks.

Similar Messages

  • [SOLVED] How to open default text editor from bash script?

    as header states i would like my script to open the desktops default text editor. I use xfce.
    I currently have it set to open medit, however i want to be able to use script on other desktops
    Last edited by orphius (2013-07-12 07:24:34)

    Trilby wrote:
    EDITOR will often not be the default desktop environment editor - it is usually limited to being a systemwide (and usually console-ready) editor.
    xdg-open, or a related tool, can give you the desktop's text editor.
    Truth. VISUAL is typically used for the graphical text editor.
    So, to use VISUAL if it exists, but otherwise default to medit, do:
    editor="${VISUAL:-medit}"
    $editor foo.txt
    Last edited by jakobcreutzfeldt (2013-07-11 07:09:02)

  • How to extract compiled stored procedure without line break for long statement

    After I compiled stored procedure which contains long statement, the statement would cut into 2 rows into dba_source.
    However, when I extract the codes from dba_source table, the source couldn't be compiled successfully because of
    the broken lines.
    For example, the following statement would be broken into 2 rows like this:
    (line 1) gv_Message := 'Interface Description: Interface with Training '|| 'and Development Intran
    (line 2) et (Evaluation Statistic Details)';

    That's very strange. What did you originally compile it with (sql*plus, toad, etc...)? I was able to compile a procedure with the maximum line length (2499 characters see error SP2-0027) and there is no split. Is the procedure in a VALID state with that line break? Honestly, this seems very odd, possibly even a bug here somewhere.
    Richard

  • ALV grid - how to break a long string into several lines?

    I have a ALV grid, where one of the fields contains a textstring that is typically 100 characters long.
    Is it possible to break this long string into shorter strings on multiple rows?
    Kind of like in Excel, when using row break...

    Thats not possible in ALV

  • How to break down long lines of code

    Is there a way to break a long line of code so that it will fit on an A4 sheet?

    You can break on most dots between variable name and method name, between spaces in operators, after a comma that separates parameter names, etc. Just about the only thing you can't break is a long literal String--though you could type it on multiple lines by breaking it into pieces and putting a + in between the pieces.

  • [JS] How to break link to paragraph style from script?

    I don't found the command break link to paragraph style from script.
    I want "unapply" the style from the text, but leave the formatting intact.
    Can help me?

    In the interface it's a separate command ("Break link to style"), but it seems in a script you have to use
    Paragraph.applyParagraphStyle (using:ParagraphStyle[, clearingOverrides:bool=true])
    You cannot use "null" or something similar for "ParagraphStyle", so I guess the idea is to use paragraph style #0 in your document (which is always "[No Paragraph Style]"). Be sure to set "clearing Overrides" to false, as it defaults to true.
    The following single line works on your current paragraph:
    app.activeDocument.selection[0].paragraphs[0].applyParagraphStyle (app.activeDocument.paragraphStyles[0], false);

  • How to download file using ftp in bash script

    Hi! I'm runnig a bash script in solaris i want within the script to dowload file using ftp
    How can i do it?
    Tanks a lot

    hello,evgchech
    please try this way:
    1. In the bash script, try following command:
    ftp -n < ftpcmdfile2 in the ftpcmdfile (which is a file),coding the interactive commands of FTP such as:
    user anonymous  [email protected]
              cd /var/sun/download
              bi
              mget *.*
              bye
         try it and good luck!
    Wang Yu
    Developer Technical Support
    Sun Microsystems
    http://sun.com/developers/support

  • How to send 2 variable value from bash script into java.class

    #!/bin/bash
      a=10
      b=20
       echo $a $b | java addition
    donehi there,
    currently i have a simple java coding ( a + b ). and i m trying to connect with bash script but this bash script coudln't Enter 2nd value (b=20) while i running for it. may i know how do i can Enter 2 value into it?
    output from terminal
    [seng@localhost java_class]$ bash addition.sh
    =======================================================================
    simulation 1
    Num_a       = 10
    Num_b       = 20
    Enter your Num_a : 10
    Enter your Num_b : Exception in thread "main" java.lang.NumberFormatException
       at java.lang.Integer.parseInt(java.lang.String, int, boolean) (/usr/lib/libgcj.so.6.0.0)
       at java.lang.Integer.parseInt(java.lang.String) (/usr/lib/libgcj.so.6.0.0)
       at filter_god.GOD(java.util.List, java.util.List, java.lang.String, java.lang.String, int) (Unknown Source)
       at filter_god.main(java.lang.String[]) (Unknown Source)
       at gnu.java.lang.MainThread.call_main() (/usr/lib/libgcj.so.6.0.0)
       at gnu.java.lang.MainThread.run() (/usr/lib/libgcj.so.6.0.0)
    =======================================================================

    That code will send both numbers on a single line in standard input to the java process. So if the process reads standard input, it will get a single line that has this in it: "10 20".
    I'm guessing you're sending that whole line to Integer.parseInt. But a valid number doesn't have a space in the middle.
    You should split up the line using String.split. Or use a StringTokenizer. Or a regular expression. Or you can use a java.util.Scanner. Or a java.io.StreamTokenizer. Or maybe some other stuff that has slipped my mind at the moment.

  • How to break a long project in 3 smaller timelines and assembling them back

    Hi,
    I'm presently working on a big project (a 90 min long documentary). I took advantage of tips from other user to speed up FCPX but now I'm at a point where I fell in need of a radical switch to give breath to my mac (btw I just switched to a new iMac with 16gb of Ram)
    I've been wondering about an advice which was gave me from Russ H on this forum: I'm presently at minute 60, he suggested me to create another timeline for the last 30 min.
    I think I have to go further ahed, I need to break the exisiting timeline in two, so to have two 30min long TL. And then I have to create a third TL with the last 30 min.
    Here we go with my questions: 1) to have new timelines I need to create/duplicate projects? Or I can just associate more timelines to the same one?
    2) If not I think I have to duplicate my project three time and then cutting the 30'min segment which I don't need to be in that project...and then of course I have to start building my third edit in the third 30min TL
    3) Here is the point which make me worried the most...At the end of my work how can I put everything back togheter? Is there any "merge TL" function? I should just export 3 masterfile and then assemble them? I should just put the 3 file on XDCAM disc as clip to be playied in a row?
    Thank you in advance for your help,
    Nico

    As I recall, the suggestion to create separate projects was one of several to address increasingly sluggish performance as your project grew in length. The idea was that by opening and working on shorter timelines, you would place less of a processing burden on your machine.
    Now that you have a newer, more powerful  iMac, it may not be necessary to break up that project.
    If you still think it is desirable to break up the project, I would stay within the existing library and create a new project for the last part of the doc.  If you are still working on the first 60 minutes section and you want to work in smaller projects, create two more empty projects. Then select two sections of the original and paste them to the new projects' timelines. When you have finished all three sections, create a fourth project and paste copies of the three into it.
    There is no merge timeline command, but copy paste is pretty bullet proof. Click in the timeline window to make it active. Hit Command-A to select all; Command -C to copy, Open the empty project and hit Command-V to copy. Just make sure that your playhead is at the last frame of the sequence before you paste any more sections into the "omnibus" timeline and it should go quite smoothly.
    Russ

  • How to break up long movie

    I have a video that is about 6 hrs in length and 10 chapter markers. I will compress as Mpeg-2 and author in dvd studio pro.
    I am assuming this will not fit on 1 disk and was wondering what would be the best way to break this up and get on multiple disks.
    thanks for the help.

    Is this an art exhibit?
    Or torture by video.
    Sometimes hard to tell the difference.
    x
    Still, Andy Warhol's 25 hour movie ★★★★ (aka Four Stars) still holds the record.
    http://www.warholstars.org/warhol/warhol1/warhol1f/stars.html

  • How to break the command line in SAP scripts

    Hi,
      Can any one Please guide me how to continue the command line( /: ) of SAP SCPRIPT into multiple lines.
    Regards
    Kiran

    Hi Kiran,
    U can continue in the same line itself by pressing SHIFT+F8
    If u want it in the next line then u can give space in the tag column.
    Thanks,
    Vinod.

  • [SOLVED] Where in path to keep my custom bash scripts

    Hey Guys,
    I apologize if this has been discussed before, I couldn't find another similar discussion in the forum.
    Having followed from another discussion I had on arch before, I finally switched from being root to a regular user. However, there is this one little problem that I have now.
    Earlier I used to stick my custom scripts in /usr/bin using symlinks. However, now, I clearly can not call these scripts from /usr/bin being a regular user. I have presently solved this problem by adding a "$HOME"/scripts folder to the path and calling my scripts from there. Everything has been tweaked to work again.
    But I'd like to know if there is a robust solution to this problem. Where should one, say a sysadmin, keep custom scripts if he'd like users to be able to use them? And what should be safe permissions on these scripts?
    Thanks for all suggestions.
    Last edited by Dumbledore (2011-09-26 16:28:31)

    Umm.. Err.. I feel like a nitwit right now! I can swear that I had tested putting my scripts in /usr/bin earlier and calling the scripts had resulted in Permission Errors even though I had checked for _execute_ permissions then.
    So I had removed those scripts from there. Now, since you asked for output, I tried putting a few scripts there again and funnily they are working now!!! Anyhoo, be that as it may, I'll check all of them and get back to this post if I find any other problem.
    Meanwhile, I'm sure that Unix has a design philosophy which divides these directories with specific intentions. So, is /usr/bin a good place to keep one's custom scripts in principle?

  • [SOLVED] problem with spaces and ls command in bash script

    I am going mad with a bash script I am trying to finish. The ls command is driving me mad with spaces in path names. This is the portion of my script that is giving me trouble:
    HOMEDIR="/home/panos/Web Site"
    for file in $(find "$HOMEDIR" -type f)
    do
    if [ "$(dateDiff -d $(ls -lh "$file" | awk '{ print $6 }') "$(date +%F)")" -gt 30 ];
    then echo -e "File $file is $(dateDiff -d $(ls -lh "$file" | awk '{ print $6 }') "$(date +%F)") old\r" >> /home/panos/scripts/temp;
    fi
    done
    The dateDiff() function is defined earlier and the script works fine when I change the HOMEDIR variable to a path where there are no spaces in directory and file names. I have isolated the problem to the ls command, so a simpler code sample that also doesn't work correctly with path names with spaces is this:
    #!/bin/bash
    HOMEDIR="/home/panos/test dir"
    for file in $(find "$HOMEDIR" -type f)
    do
    ls -lh "$file"
    done
    TIA
    Last edited by panosk (2009-11-08 21:55:31)

    oops, brain fart. *flushes with embarrassment*
    -- Edit --
    BTW, for this kind of thing, I usually do something like:
    find "$HOMEDIR" -type f | while read file ; do something with "$file" ; done
    Or put those in an array:
    IFS=$'\n' ; files=($(find "$HOMEDIR" -type f)) ; unset IFS
    for file in "${files[@]}" ; do something with "$file" ; done
    The later method is useful when elements of "${files[@]}" will be used multiple times across the script.
    Last edited by lolilolicon (2009-11-09 08:13:07)

  • How to use an if statement in javascript code

    Hello,
    I have a batch processing script to search for text "employee signature" on each page in a multiple page file and to then list in the console any pages that do not have the "Employee Signature" text included.
    The script is not yet functional as an if statement needs to be included.
    Can anyone please advise how to use an if statement in javascript code?
    var numpages = this.numPages;
    for (var i=0; i < numpages; i++)
    search.query("Employee Signature", "ActiveDoc");
    console.println('Pages that do not include an employee signature: ' + this.pageNum +' ');
    Any assistance will be most appreciated.

    Thank you very much for your assistance try.
    I have modified the code as suggested and the page numbers are now listing correctly, thank you, but....................,
    The console  lists every page as having an "employee signature" when there are pages in the document that do not have an employee signature.
    The code (revised as follows) is not processing the "getPageNthWord part of the statement" in the console report?
    Can you please advise where the code needs reworking?
    var ckWords; // word pair to test
    var bFound = false; // logical status of found words
    // loop through pages
    for (var i = 0; i < this.numPages; i++ ) {
       bFound = false; // set found flag to false
       numWords = this.getPageNumWords(i); // number of words on page
       // loop through the words on page
       for (var j = 0; j < numWords; j++) {
          // get word pair to test
          ckWords = this.getPageNthWord(i, j) + ' ' + this.getPageNthWord(i, j + 1); // test words
          // check to see if word pair is 'Employee' string is present
          if ( ckWord == "Employee") {
             bFound = true; // indicate found logical value
             console.println('Pages that includes an employee signature: ' + (i + 1) +' ');
             break; // no need to further test for this page
          } // end Employee Signature
       } // end word loop
       // test to see if words not found
       if(bFound == false) {
             console.println('Pages that do include an employee signature: ' + (i + 1) +' ');
        } // end not found on page  
    } // end page loop
    Thank you

  • How to debugg particular statement in sap script

    hi friends,
    i want to know How to debugg particular statement in sap script.
    plz reply.
    thanks in advance,
    regards
    bhaskar

    hi
      execute rstxdbug to activate script debugger...once the driver program reaches open_form, a popup box will come where u can mention the name of a command, call functinon, text element, etc to place a break point...once it gets into the debugging mode, double click on any line to set a break point, after that pressing f8 will get you to that line
    if helpful, reward
    Sathish. R

Maybe you are looking for

  • Next button not working in advanced table

    HI , I have created an advanced table programatically.everything is working fine but the navigation buttons for next and previous are not working properly.If I click on next 20 records I am getting the first 20 records.Do i need to set anything for t

  • Can't see any photos in media browser in other apps

    I have my iPhoto library on an external drive due to its size as well as multiple user profiles on this box. No problem when I open iPhoto everything shows up all nice and organized, but if I'm working in another app that uses the media browser to al

  • Update OpenQuey is not working ?

    Hi, I have Universal U2 server and connecting with linked server from SQL server 2012. But unable to update data in the linked server. DECLARE @Sql2 VARCHAR(8000) SET @Sql2 = 'SELECT * FROM TABLE_NAME WHERE Z_ID=''P112598''' SET @Sql2 = 'UPDATE OPENQ

  • DATABASE QUERY

    I have connected to an Access database using a servlit. I have another program within the servlit that calculates a score. This score has to recorded in the database, this is all fine. My problem is this, the rules state a user can only submit a maxi

  • Problem with starting Windows

    I am user of Toshiba Satellite A205- S5879. It has worked correctly but lately i hava a problem. When I try to turn on my computer it shows only a screen with text: "Toshiba, leading innovation" if I press F2 i have opportunity to choose some options