Search Results

Search found 2253 results on 91 pages for 'grep'.

Page 12/91 | < Previous Page | 8 9 10 11 12 13 14 15 16 17 18 19  | Next Page >

  • Selectively search and replace certain lines using a regular expression

    - by eneveu
    I have a file containing a lot of SQL statements, such as: CREATE TABLE "USER" ( "ID" INTEGER PRIMARY KEY, "NAME" CHARACTER VARYING(50) NOT NULL, "AGE" INTEGER NOT NULL ); COPY "USER" (id, name, age) FROM stdin; 1 Skywalker 19 2 Kenobi 57 I want the column names in the COPY statements to be uppercased and quoted: COPY "USER" ("ID", "NAME", "AGE") FROM stdin; Using sed, I found the following regexp: sed -r 's/([( ])(\w+)([,)])/\1"\U\2\E"\3/g' It does replace the column names, but it is not selective enough, and replaces other words in the file: ~/test]$sed -r 's/([( ])(\w+)([,)])/\1"\U\2\E"\3/g' star_wars_example CREATE TABLE "USER" ( "ID" INTEGER PRIMARY "KEY", "NAME" CHARACTER VARYING("50")NOT "NULL", "AGE" INTEGER NOT NULL ); COPY "USER" ("ID", "NAME", "AGE") FROM stdin; 1 Skywalker 19 2 Kenobi 57 To avoid this problem, I want sed to only apply my regexp to the lines starting with COPY and ending with FROM stdin;. I have looked into lookahead / lookbehind, but they are not supported in sed. They seem to be supported in super-sed, but I am currently using Cygwin (Windows is mandatory here...) and it does not seem available in the package list. Is there a way to force sed to only consider specific line? I've considered piping my file through grep before applying sed, but other lines will then disappear from the output. Am I missing something obvious? It would be great if the answer was easily applicable on a default Cygwin install. I guess I could try installing super-sed on cygwin, but I'd like to know if there are more obvious ideas

    Read the article

  • Copy/publish images linked from the html files to another server and update the HTML files referenci

    - by Phil
    I am publishing content from a Drupal CMS to static HTML pages on another domain, hosted on a second server. Building the HTML files was simple (using PHP/MySQL to write the files). I have a list of images referenced in my HTML, all of which exist below the /userfiles/ directory. cat *.html | grep -oE [^\'\"]+userfiles[\/.*]*/[^\'\"] | sort | uniq Which produces a list of files http://my.server.com/userfiles/Another%20User1.jpg http://my.server.com/userfiles/image/image%201.jpg ... My next step is to copy these images across to the second server and translate the tags in the html files. I understand that sed is probably the tool I would need. E.g.: sed 's/[^"]\+userfiles[\/image]\?\/\([^"]\+\)/\/images\/\1/g' Should change http://my.server.com/userfiles/Another%20User1.jpg to /images/Another%20User1.jpg, but I cannot work out exactly how I would use the script. I.e. can I use it to update the files in place or do I need to juggle temporary files, etc. Then how can I ensure that the files are moved to the correct location on the second server

    Read the article

  • How can I get `find` to ignore .svn directories?

    - by John Kugelman
    I often use the find command to search through source code, delete files, whatever. Annoyingly, because Subversion stores duplicates of each file in its .svn/text-base/ directories my simple searches end up getting lots of duplicate results. For example, I want to recursively search for uint in multiple messages.h and messages.cpp files: # find -name 'messages.*' -exec grep -Iw uint {} + ./messages.cpp: Log::verbose << "Discarding out of date message: id " << uint(olderMessage.id) ./messages.cpp: Log::verbose << "Added to send queue: " << *message << ": id " << uint(preparedMessage->id) ./messages.cpp: Log::error << "Received message with invalid SHA-1 hash: id " << uint(incomingMessage.id) ./messages.cpp: Log::verbose << "Received " << *message << ": id " << uint(incomingMessage.id) ./messages.cpp: Log::verbose << "Sent message: id " << uint(preparedMessage->id) ./messages.cpp: Log::verbose << "Discarding unsent message: id " << uint(preparedMessage->id) ./messages.cpp: for (uint i = 0; i < 10 && !_stopThreads; ++i) { ./.svn/text-base/messages.cpp.svn-base: Log::verbose << "Discarding out of date message: id " << uint(olderMessage.id) ./.svn/text-base/messages.cpp.svn-base: Log::verbose << "Added to send queue: " << *message << ": id " << uint(preparedMessage->id) ./.svn/text-base/messages.cpp.svn-base: Log::error << "Received message with invalid SHA-1 hash: id " << uint(incomingMessage.id) ./.svn/text-base/messages.cpp.svn-base: Log::verbose << "Received " << *message << ": id " << uint(incomingMessage.id) ./.svn/text-base/messages.cpp.svn-base: Log::verbose << "Sent message: id " << uint(preparedMessage->id) ./.svn/text-base/messages.cpp.svn-base: Log::verbose << "Discarding unsent message: id " << uint(preparedMessage->id) ./.svn/text-base/messages.cpp.svn-base: for (uint i = 0; i < 10 && !_stopThreads; ++i) { ./virus/messages.cpp:void VsMessageProcessor::_progress(const string &fileName, uint scanCount) ./virus/messages.cpp:ProgressMessage::ProgressMessage(const string &fileName, uint scanCount) ./virus/messages.h: void _progress(const std::string &fileName, uint scanCount); ./virus/messages.h: ProgressMessage(const std::string &fileName, uint scanCount); ./virus/messages.h: uint _scanCount; ./virus/.svn/text-base/messages.cpp.svn-base:void VsMessageProcessor::_progress(const string &fileName, uint scanCount) ./virus/.svn/text-base/messages.cpp.svn-base:ProgressMessage::ProgressMessage(const string &fileName, uint scanCount) ./virus/.svn/text-base/messages.h.svn-base: void _progress(const std::string &fileName, uint scanCount); ./virus/.svn/text-base/messages.h.svn-base: ProgressMessage(const std::string &fileName, uint scanCount); ./virus/.svn/text-base/messages.h.svn-base: uint _scanCount; How can I tell find to ignore the .svn directories?

    Read the article

  • Why does a bash-zenity script has that title on Unity Panel and that icon on Unity Launcher?

    - by Sadi
    I have this small bash script which helps use Infinality font rendering options via a more user-friendly Zenity window. But whenever I launch it I have this "Color Picker" title on Unity Panel together with the icon assigned for "Color Picker" utility. I wonder why and how this is happening and how I can change it? #!/bin/bash # A simple script to provide a basic, zenity-based GUI to change Infinality Style. # v.1.2 # infinality_current=`cat /etc/profile.d/infinality-settings.sh | grep "USE_STYLE=" | awk -F'"' '{print $2}'` sudo_password="$( gksudo --print-pass --message 'Provide permission to make system changes: Enter your password to start or press Cancel to quit.' -- : 2>/dev/null )" # Check for null entry or cancellation. if [[ ${?} != 0 || -z ${sudo_password} ]] then # Add a zenity message here if you want. exit 4 fi # Check that the password is valid. if ! sudo -kSp '' [ 1 ] <<<"${sudo_password}" 2>/dev/null then # Add a zenity message here if you want. exit 4 fi # menu(){ im="zenity --width=500 --height=490 --list --radiolist --title=\"Change Infinality Style\" --text=\"Current <i>Infinality Style</i> is\: <b>$infinality_current</b>\n? To <i>change</i> it, select any other option below and press <b>OK</b>\n? To <i>quit without changing</i>, press <b>Cancel</b>\" " im=$im" --column=\" \" --column \"Options\" --column \"Description\" " im=$im"FALSE \"DEFAULT\" \"Use default settings - a compromise that should please most people\" " im=$im"FALSE \"OSX\" \"Simulate OSX rendering\" " im=$im"FALSE \"IPAD\" \"Simulate iPad rendering\" " im=$im"FALSE \"UBUNTU\" \"Simulate Ubuntu rendering\" " im=$im"FALSE \"LINUX\" \"Generic Linux style - no snapping or certain other tweaks\" " im=$im"FALSE \"WINDOWS\" \"Simulate Windows rendering\" " im=$im"FALSE \"WIN7\" \"Simulate Windows 7 rendering with normal glyphs\" " im=$im"FALSE \"WINLIGHT\" \"Simulate Windows 7 rendering with lighter glyphs\" " im=$im"FALSE \"VANILLA\" \"Just subpixel hinting\" " im=$im"FALSE \"CLASSIC\" \"Infinality rendering circa 2010 - No snapping.\" " im=$im"FALSE \"NUDGE\" \"Infinality - Classic with lightly stem snapping and tweaks\" " im=$im"FALSE \"PUSH\" \"Infinality - Classic with medium stem snapping and tweaks\" " im=$im"FALSE \"SHOVE\" \"Infinality - Full stem snapping and tweaks without sharpening\" " im=$im"FALSE \"SHARPENED\" \"Infinality - Full stem snapping, tweaks, and Windows-style sharpening\" " im=$im"FALSE \"INFINALITY\" \"Infinality - Standard\" " im=$im"FALSE \"DISABLED\" \"Act without extra infinality enhancements - just subpixel hinting\" " } # option(){ choice=`echo $im | sh -` # if echo $choice | grep "DEFAULT" > /dev/null; then sudo -Sp '' sed -i "s/USE_STYLE=\"${infinality_current}\"/USE_STYLE=\"DEFAULT\"/g" '/etc/profile.d/infinality-settings.sh' <<<"${sudo_password}" fi # if echo $choice | grep "OSX" > /dev/null; then sudo -Sp '' sed -i "s/USE_STYLE=\"${infinality_current}\"/USE_STYLE=\"OSX\"/g" '/etc/profile.d/infinality-settings.sh' <<<"${sudo_password}" fi # if echo $choice | grep "IPAD" > /dev/null; then sudo -Sp '' sed -i "s/USE_STYLE=\"${infinality_current}\"/USE_STYLE=\"IPAD\"/g" '/etc/profile.d/infinality-settings.sh' <<<"${sudo_password}" fi # if echo $choice | grep "UBUNTU" > /dev/null; then sudo -Sp '' sed -i "s/USE_STYLE=\"${infinality_current}\"/USE_STYLE=\"UBUNTU\"/g" '/etc/profile.d/infinality-settings.sh' <<<"${sudo_password}" fi # if echo $choice | grep "LINUX" > /dev/null; then sudo -Sp '' sed -i "s/USE_STYLE=\"${infinality_current}\"/USE_STYLE=\"LINUX\"/g" '/etc/profile.d/infinality-settings.sh' <<<"${sudo_password}" fi # if echo $choice | grep "WINDOWS" > /dev/null; then sudo -Sp '' sed -i "s/USE_STYLE=\"${infinality_current}\"/USE_STYLE=\"WINDOWS\"/g" '/etc/profile.d/infinality-settings.sh' <<<"${sudo_password}" fi # if echo $choice | grep "WIN7" > /dev/null; then sudo -Sp '' sed -i "s/USE_STYLE=\"${infinality_current}\"/USE_STYLE=\"WINDOWS7\"/g" '/etc/profile.d/infinality-settings.sh' <<<"${sudo_password}" fi # if echo $choice | grep "WINLIGHT" > /dev/null; then sudo -Sp '' sed -i "s/USE_STYLE=\"${infinality_current}\"/USE_STYLE=\"WINDOWS7LIGHT\"/g" '/etc/profile.d/infinality-settings.sh' <<<"${sudo_password}" fi # if echo $choice | grep "VANILLA" > /dev/null; then sudo -Sp '' sed -i "s/USE_STYLE=\"${infinality_current}\"/USE_STYLE=\"VANILLA\"/g" '/etc/profile.d/infinality-settings.sh' <<<"${sudo_password}" fi # if echo $choice | grep "CLASSIC" > /dev/null; then sudo -Sp '' sed -i "s/USE_STYLE=\"${infinality_current}\"/USE_STYLE=\"CLASSIC\"/g" '/etc/profile.d/infinality-settings.sh' <<<"${sudo_password}" fi # if echo $choice | grep "NUDGE" > /dev/null; then sudo -Sp '' sed -i "s/USE_STYLE=\"${infinality_current}\"/USE_STYLE=\"NUDGE\"/g" '/etc/profile.d/infinality-settings.sh' <<<"${sudo_password}" fi # if echo $choice | grep "PUSH" > /dev/null; then sudo -Sp '' sed -i "s/USE_STYLE=\"${infinality_current}\"/USE_STYLE=\"PUSH\"/g" '/etc/profile.d/infinality-settings.sh' <<<"${sudo_password}" fi # if echo $choice | grep "SHOVE" > /dev/null; then sudo -Sp '' sed -i "s/USE_STYLE=\"${infinality_current}\"/USE_STYLE=\"SHOVE\"/g" '/etc/profile.d/infinality-settings.sh' <<<"${sudo_password}" fi # if echo $choice | grep "SHARPENED" > /dev/null; then sudo -Sp '' sed -i "s/USE_STYLE=\"${infinality_current}\"/USE_STYLE=\"SHARPENED\"/g" '/etc/profile.d/infinality-settings.sh' <<<"${sudo_password}" fi # if echo $choice | grep "INFINALITY" > /dev/null; then sudo -Sp '' sed -i "s/USE_STYLE=\"${infinality_current}\"/USE_STYLE=\"INFINALITY\"/g" '/etc/profile.d/infinality-settings.sh' <<<"${sudo_password}" fi # if echo $choice | grep "DISABLED" > /dev/null; then sudo -Sp '' sed -i "s/USE_STYLE=\"${infinality_current}\"/USE_STYLE=\"DISABLED\"/g" '/etc/profile.d/infinality-settings.sh' <<<"${sudo_password}" fi # } # menu option # if test ${#choice} -gt 0; then echo "Operation completed" fi # exit 0

    Read the article

  • Powerful search-replace GUI app for Mac?

    - by fig-gnuton
    What's the best dedicated search-and-replace GUI tool on a Mac? "Find & Replace It!" seems decent, but they've ridiculously disabled the replace function in the demo, so I can't give it a real test before paying. Is there anything else comparable or better?

    Read the article

  • UNIX Parse HTML Page Display Contents of a Tag - One Liner?

    - by NJTechie
    I have an HTML file and I am interested in the data enclosed by <pre> </pre> tags. Is there a one-liner that can do achieve this? Sample file : <html> <title> Hello There! </title> <body> <pre> John Working Kathy Working Mary Working Kim N/A </pre> </body> </html> Output should be : John Kathy Mary Kim Much appreciated guys, thank you!

    Read the article

  • using Awk inside Perl script

    - by papoyan
    My first question in stackoverflow! I'm having trouble using the following code inside my perl script, any advise is really appreciated, how to correct the syntax? # If I execute in bash, it's working just fine bash$ whois google.com | egrep "\w+([._-]\w)*@\w+([._-]\w)*\.\w{2,4}" |awk ' {for (i=1;i<=NF;i++) {if ( $i ~ /[[:alpha:]]@[[:alpha:]]/ ) { print $i}}}'|head -n1 [email protected] #----------------------------------- #but this doesn't work bash$ ./email.pl google.com awk: {for (i=1;i<=NF;i++) {if ( ~ /[[:alpha:]]@[[:alpha:]]/ ) { print }}} awk: ^ syntax error # Here is my script bash$ cat email.pl ####\#!/usr/bin/perl $input = lc shift @ARGV; $host = $input; my $email = `whois $host | egrep "\w+([._-]\w)*@\w+([._-]\w)*\.\w{2,4}" |awk ' {for (i=1;i<=NF;i++) {if ( $i ~ /[[:alpha:]]@[[:alpha:]]/ ) { print $i}}}'|head -1`; print my $email; bash$ Thank you in advance !

    Read the article

  • Approximate string matching with a letter confusion matrix?

    - by zigglenaut
    I'm trying to model a phonetic recognizer that has to isolate instances of words (strings of phones) out of a long stream of phones that doesn't have gaps between each word. The stream of phones may have been poorly recognized, with letter substitutions/insertions/deletions, so I will have to do approximate string matching. However, I want the matching to be phonetically-motivated, e.g. "m" and "n" are phonetically similar, so the substitution cost of "m" for "n" should be small, compared to say, "m" and "k". So, if I'm searching for [mein] "main", it would match the letter sequence [meim] "maim" with, say, cost 0.1, whereas it would match the letter sequence [meik] "make" with, say, cost 0.7. Similarly, there are differing costs for inserting or deleting each letter. I can supply a confusion matrix that, for each letter pair (x,y), gives the cost of substituting x with y, where x and y are any letter or the empty string. I know that there are tools available that do approximate matching such as agrep, but as far as I can tell, they do not take a confusion matrix as input. That is, the cost of any insertion/substitution/deletion = 1. My question is, are there any open-source tools already available that can do approximate matching with confusion matrices, and if not, what is a good algorithm that I can implement to accomplish this?

    Read the article

  • How do I extract the values from this data using bash and awk?

    - by ben Rod
    I grepped these, how do I extract the values? ... cavity_2mgl_wt_strip57001.out: Total cavity volume (A3) : ( 1.240E+01) cavity_2mgl_wt_strip58001.out: Total cavity volume (A3) : ( 2.408E+00) cavity_2mgl_wt_strip60001.out: Total cavity volume (A3) : ( 4.935E+00) cavity_2mgl_wt_strip61001.out: Total cavity volume (A3) : ( 1.319E+00) cavity_2mgl_wt_strip63001.out: Total cavity volume (A3) : ( 1.532E-01) cavity_2mgl_wt_strip64001.out: Total cavity volume (A3) : ( 1.137E+01) ... and I need the index # in the filename in bold: cavity_2mgl_wt_strip76001.out: Total cavity volume (A3) : ( 1.276E+01) and I need the number in the parenthesis cavity_2mgl_wt_strip76001.out: Total cavity volume (A3) : ( **1.276E+01**)

    Read the article

  • How can I extract all quotations in a text?

    - by secr
    I'm looking for a SimpleGrepSedPerlOrPythonOneLiner that outputs all quotations in a text. Example 1: echo “HAL,” noted Frank, “said that everything was going extremely well.” | SimpleGrepSedPerlOrPythonOneLiner stdout: "HAL," "said that everything was going extremely well.” Example 2: cat MicrosoftWindowsXPEula.txt | SimpleGrepSedPerlOrPythonOneLiner stdout: "EULA" "Software" "Workstation Computer" "Device" "DRM" etc. (link to the corresponding text).

    Read the article

  • Why doesn't this simple regex match what I think it should?

    - by Kevin Stargel
    I have a data file that looks like the following example. I've added '%' in lieu of \t, the tab control character. 1234:56% Alice Worthington alicew% Jan 1, 2010 10:20:30 AM% Closed% Development Digg: Reddit: Update%% file-one.txt% 1.1% c:/foo/bar/quux Add%% file-two.txt% 2.5.2% c:/foo/bar/quux Remove%% file-three.txt% 3.4% c:/bar/quux Update%% file-four.txt% 4.6.5.3% c:/zzz ... many more records of the above form The records I'm interested in are the lines beginning with "Update", "Add", "Remove", and so on. I won't know what the lines begin with ahead of time, or how many lines precede them. I do know that they always begin with a string of letters followed by two tabs. So I wrote this regex: generate-report-for 1234:56 | egrep "^[[:alpha:]]+\t\t.+" But this matches zero lines. Where did I go wrong? Edit: I get the same results whether I use '...' or "..." for the egrep expression, so I'm not sure it's a shell thing.

    Read the article

  • Help with Perl Regex Recursive Replace One Liner? Replace MySQL comments '--' with '#'

    - by NJTechie
    I have various SQL files with '--' comments and we migrated to the latest version of MySQL and it hates these comments. I want to replace -- with #. I am looking for a recursive, inplace replace one-liner. This is what I have : perl -p -i -e 's/--/# /g' `fgrep -- -- * ` A sample .sql file : use myDB; --did you get an error I get the following error : Unrecognized switch: --did (-h will show valid options). p.s : fgrep skipping 2 dashes was just discussed here if you are interested. Any help is appreciated.

    Read the article

  • how to substract numbers from levels

    - by romunov
    Dear SOFers, I would like to cut a vector of values ranging 0-70 to x number of categories, and would like the upper limit of each category. So far, I have tried this using cut() and am trying to extract the limits from levels. I have a list of levels, from which I would like to extract the second number from each level. How can I extract the values between space and ] (which is the number I'm interested in)? I have: > levels(bins) [1] "(-0.07,6.94]" "(6.94,14]" "(14,21]" "(21,28]" "(28,35]" [6] "(35,42]" "(42,49]" "(49,56]" "(56,63.1]" "(63.1,70.1]" and would like to get: [1] 6.94 14 21 28 35 42 49 56 63.1 70.1 Or is there a better way of calculating the upper bounds of categories?

    Read the article

  • How do I get Git's latest stable release version number?

    - by MattDiPasquale
    I'm writing a git-install.sh script: http://gist.github.com/419201 To get Git's latest stable release version number, I do: LSR_NUM=$(curl -silent http://git-scm.com/ | sed -n '/id="ver"/ s/.*v\([0-9].*\)<.*/\1/p') 2 Questions: Refactor my code: Is there a better way programmatically to do this? This works now, but it's brittle: if the web page at http://git-scm.com/ changes, the line above may stop working. PHP has a reliable URL for getting the latest release version: http://stackoverflow.com/questions/288206/is-there-a-site-which-simply-outputs-the-latest-stable-version-numbers-of-php-and Is there something like this for Git? This comes close: http://www.kernel.org/pub/software/scm/git/

    Read the article

  • shell script filter du and find by a string inside a file in a subfolder

    - by Jason
    I have the following command that I run on cygwin: find /cygdrive/d/tmp/* -maxdepth 0 -mtime -150 -type d | xargs du --max-depth=0 > foldersizesreport.csv I intended to do the following with this command: for each folder under /d/tmp/ that was modified in last 150 days, check its total size including files within it and report it to file foldersizesreport.csv however that is now not good enough for me, as it turns out inside each /d/tmp/subfolder1/somefile.properties /d/tmp/subfolder2/somefile.properties /d/tmp/subfolder3/somefile.properties /d/tmp/subfolder4/somefile.properties so as you see inside each subfolderX there is a file named somefile.properties inside it there is a property SOMEPROPKEY=3808612800100 (among other properties) this is the time in millisecond, i need to change the command so that instead of -mtime -150 it will include in the whole calculation only subfolderX that has a file inside them somefile.properties where the SOMEPROPKEY=3808612800100 is the time in millisecond in future, if the value SOMEPROPKEY=23948948 is in past then dont at all include the folder in the foldersizesreport.csv because its not relevant to me. so the result report should be looking like: /d/tmp/,subfolder1,<itssizein KB> /d/tmp/,subfolder2,<itssizein KB> and if subfolder3 had a SOMEPROPKEY=34243234 (time in ms in past) then it would not be in that csv file. so basically I'm looking for: find /cygdrive/d/tmp/* -maxdepth 0 -mtime -150 -type d | <only subfolders that have in them property in file SOMEPROPKEY=28374874827 - time in ms in future and not in past | xargs du --max-depth=0 > foldersizesreport.csv

    Read the article

  • Linux - Want To Check For Possible Duplicate Directories (Probably RegEx Needed)

    - by NoLongerHere
    Hi, I have a directory which contains several directories as follows: /Music/ /Music/JoeBlogs-Back_In_Black-1980 /Music/JoeBlogs-Back_In_Black-(Remastered)-2003 /Music/JoeBlogs-Back_In_Black-(ReIssue)-1987 /Music/JoeBlogs-Thunder_Man-1947 I want a script to go through and tell me when there are 'possible' duplicates, in the example above it would pick up the following as possible duplicates from the directory list: /Music/JoeBlogs-Back_In_Black-1980 /Music/JoeBlogs-Back_In_Black-(Remastered)-2003 /Music/JoeBlogs-Back_In_Black-(ReIssue)-1987 1) Is this possible? 2) If so please help!

    Read the article

  • Problem with Replace in Eclipse

    - by Imran
    I'm using regex to match all non-quoted property names in my json files. Eclipse has no problem finding the desired matches, but when I want to replace the matched strings with "$2", I get this error: Match string has changed in file filename.json. Match skipped Here's the regex I'm using: `((\w+)\s*(?!['"])(?=:))` Any idea on how to work around this issue?

    Read the article

  • filter log file by defining regexes

    - by fmpdmb
    I have some HUGE log files (50Mb; ~500K lines) I need to start filtering some of the crap out of. The log files are being produced using log4j and have the basic pattern of: [log-level] date-time class etc, etc log-message I'm looking for a way that I can identify a regex start and regex end (or something similar) that will filter out the matching entries from the file so I can more easily wade through these massive files. I'm sure I could write a java program to accomplish this task, but I thought I'd ask the community before going down that path. Thanks in advance.

    Read the article

  • How to perform an action when file changed?

    - by ZeissS
    Hi, I want to create a script that checks an URL and perform an action (download + unzip) when the "Last-Modified" header of the remote file changed. I thought about fetching the header with curl but then I have to store it somewhere for each file and perform a date comparison. Does anyone have a different idea using (mostly) standard unix tools? thanks

    Read the article

  • bash script to find/grep particular string in xml files in particular folders

    - by user3702188
    i have a problem at work, where i need to simplify the process how i searrh for logs. I would like to ask for help from experts here. We have different services for every channel. The structure is following: - root/channel_1/service_1/2014-05-21/file_54544654541.xml - root/channel_1/server2_2/2014-05-20/file_74272172.xml - root/channel_1/service_3/2014-05-22/file_45456546.xml - root/channel_2/service_4/2014-05-23/file_78754456.xml - root/channel_2/service_5/2014-05-24/file_546546546.xml my main problem is to find particular string in these xml files. Lets say, i know the channel name but i dont know the service name under which my particular string should be present. Also i know the date. So in search i want to enter the channel name the date and string. The search would be going via all service folders and looking for string only in all xml files under particular date folder and particular channel. any ideas for quickest and easiest solution to achieve this? Either by bash or perl? Any help would be appreciated thanks

    Read the article

  • How to perform an action when a remote (Http) file changed?

    - by ZeissS
    Hi, I want to create a script that checks an URL and perform an action (download + unzip) when the "Last-Modified" header of the remote file changed. I thought about fetching the header with curl but then I have to store it somewhere for each file and perform a date comparison. Does anyone have a different idea using (mostly) standard unix tools? thanks

    Read the article

  • Bash-Scripting - Munin Plugin don't work

    - by FTV Admin
    i have written a munin-plugin to count the http-statuscodes of lighttpd. The script: #!/bin/bash ###################################### # Munin-Script: Lighttpd-Statuscodes # ###################################### ##Config # path to lighttpd access.log LIGHTTPD_ACCESS_LOG_PATH="/var/log/lighttpd/access.log" # rows to parse in logfile (higher value incrase time to run plugin. if value to low you may get bad counting) LOG_ROWS="200000" # #munin case $1 in autoconf) # check config AVAILABLE=`ls $LIGHTTPD_ACCESS_LOG_PATH` if [ "$AVAILABLE" = "$LIGHTTPD_ACCESS_LOG_PATH" ]; then echo "yes" else echo "No: "$AVAILABLE echo "Please check your config!" fi exit 0;; config) # graph config cat <<'EOM' graph_title Lighhtpd Statuscodes graph_vlabel http-statuscodes / min graph_category lighttpd 1xx.label 1xx 2xx.label 2xx 3xx.label 3xx 4xx.label 4xx 5xx.label 5xx EOM exit 0;; esac ## calculate AVAILABLE=`ls $LIGHTTPD_ACCESS_LOG_PATH` if [ "$AVAILABLE" = "$LIGHTTPD_ACCESS_LOG_PATH" ]; then TIME_NOW=`date` CODE_1xx="0" CODE_2xx="0" CODE_3xx="0" CODE_4xx="0" CODE_5xx="0" for i in 1 2 3 4 5; do TIME5=`date +%d/%b/%Y:%k:%M --date "$TIME_NOW -"$i"min"` CODE_1xx=$(( $CODE_1xx + `tail -n $LOG_ROWS $LIGHTTPD_ACCESS_LOG_PATH | grep "$TIME5" | grep 'HTTP/1.1" 1' | grep -c " "` )) CODE_2xx=$(( $CODE_2xx + `tail -n $LOG_ROWS $LIGHTTPD_ACCESS_LOG_PATH | grep "$TIME5" | grep 'HTTP/1.1" 2' | grep -c " "` )) CODE_3xx=$(( $CODE_3xx + `tail -n $LOG_ROWS $LIGHTTPD_ACCESS_LOG_PATH | grep "$TIME5" | grep 'HTTP/1.1" 3' | grep -c " "` )) CODE_4xx=$(( $CODE_4xx + `tail -n $LOG_ROWS $LIGHTTPD_ACCESS_LOG_PATH | grep "$TIME5" | grep 'HTTP/1.1" 4' | grep -c " "` )) CODE_5xx=$(( $CODE_5xx + `tail -n $LOG_ROWS $LIGHTTPD_ACCESS_LOG_PATH | grep "$TIME5" | grep 'HTTP/1.1" 5' | grep -c " "` )) done CODE_1xx=$(( $CODE_1xx / 5 )) CODE_2xx=$(( $CODE_2xx / 5 )) CODE_3xx=$(( $CODE_3xx / 5 )) CODE_4xx=$(( $CODE_4xx / 5 )) CODE_5xx=$(( $CODE_5xx / 5 )) echo "1xx.value "$CODE_1xx echo "2xx.value "$CODE_2xx echo "3xx.value "$CODE_3xx echo "4xx.value "$CODE_4xx echo "5xx.value "$CODE_5xx else echo "1xx.value U" echo "2xx.value U" echo "3xx.value U" echo "4xx.value U" echo "5xx.value U" fi If i run the script on local machine it runs perfectly: root@server1 /etc/munin/plugins # ll lrwxrwxrwx 1 root root 45 2011-12-19 15:23 lighttpd_statuscodes -> /usr/share/munin/plugins/lighttpd_statuscodes* root@server1 /etc/munin/plugins # ./lighttpd_statuscodes autoconf yes root@server1 /etc/munin/plugins # ./lighttpd_statuscodes config graph_title Lighhtpd Statuscodes graph_vlabel http-statuscodes / min graph_category lighttpd 1xx.label 1xx 2xx.label 2xx 3xx.label 3xx 4xx.label 4xx 5xx.label 5xx root@server1 /etc/munin/plugins #./lighttpd_statuscodes 1xx.value 0 2xx.value 5834 3xx.value 1892 4xx.value 0 5xx.value 0 But Munin shows no graph: http://s1.directupload.net/images/111219/3psgq3vb.jpg I have tested the Plugin from munin-server via telnet: root@munin-server /etc/munin/plugins/ # telnet 123.123.123.123 4949 Trying 123.123.123.123... Connected to 123.123.123.123. Escape character is '^]'. # munin node at server1.cluster1 fetch lighttpd_statuscodes 1xx.value U 2xx.value U 3xx.value U 4xx.value U 5xx.value U . Connection closed by foreign host. You can see in the script that value = U only printed, when the script can't check the lighttpd's access.log. But why can't script do it, when running via munin, and when running on local machine all is ok? Is there a bug in my bash-script? I have no Idea. Thanks for helping!

    Read the article

  • Comments in a multi-line bash command

    - by Nicolas Raoul
    This single-command BASH script file is difficult to understand, so I want to write a comment for each of the actions: grep -R "%" values* \ | sed -e "s/%/\n%/" \ | grep "%" \ | grep -v " % " \ | grep -v " %<" \ | grep -v "%s" \ | grep -v "%d" \ | grep -v "%1$s" I would hate having to duplicate lines, or having each comment far away from the line it applies to. But at the same time BASH does not seem to allow "in-line" comments. Any elegant way to solve this problem?

    Read the article

< Previous Page | 8 9 10 11 12 13 14 15 16 17 18 19  | Next Page >