Search Results

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

Page 9/91 | < Previous Page | 5 6 7 8 9 10 11 12 13 14 15 16  | Next Page >

  • Find files containing a string on the whole filesystem

    - by Fabio
    I need to find all the instances of a given string in the whole filesystem, because I don't remember in which configuration files, script or any other programs I put it and I need to update that string with a new one. I tried with the following command `grep -nr 'needle' / --exclude-dir=.svn | mail [email protected] -s 'References on xxx' If I run this command on a small directory it gives me the output I need in the form /path1/:nn:line containing needle /path2/:nn:line containing needle where /path1 is the full path of the file, nn is the row containing the needle and last field is the content of the line. However when I run the command on the root directory the grep process hang after a while. I run this script about 8 hours ago and even on a small filesystem (less than 5GB) it doesn't end and if I run top or ps the process seems sleeping root 24909 0.0 0.1 3772 1520 pts/1 S+ Feb10 0:15 grep -nr needle / --exclude-dir=.svn Why it doesn't end? Is there any better way to do this (it's a one time job, I don't need to execute this more than once) Thanks.

    Read the article

  • Filtering out emoticons using sed

    - by user349222
    Hello, I have a grep expression using cygwin grep on Win. grep -a "\\,,/\|\\m/\|\\m/\\>\.</\\m/\|:u" all_fbs.txt > rockon_fbs.txt Once I identify the emoticon class, however, I want to strip them out of the data. However, the same regexp above within a sed results in a syntax error (yes, I realize I could use /d instead of //g, but this doesn't make a difference, I still get the error.) sed "s/\(\\,,/\|\\m/\|\\m/\\>\.</\\m/\|:u\)*//g" The full line is: grep -a "\\,,/\|\\m/\|\\m/\\>\.</\\m/\|:u" all_fbs.txt | sed "s/\(\\,,/\|\\m/\|\\m/\\>\.</\\m/\|:u\)*//g" | sed "s/^/ROCKON\t/" > rockon_fbs.txt The result is: sed: -e expression #1, char 14: unknown option to `s' I know it's coming from the sed regexp I'm asking about it b/c if I remove that portion of the full line, then I get no error (but, of course, the emoticons are not filtered out). Thanks in advance, Steve

    Read the article

  • Working with arrays passed byref

    - by Jason
    I would like for someone to explain this to me: function myFunction(array){ array = $.grep(array, function(n,i){return n > 1 }); } var mainArray = [1,2,3]; myFunction(mainArray); document.write(mainArray) // 1,2,3, but i'm expecting 2,3 but if i do something like array[3] = 4; in place of the $.grep line, i get 1,2,3,4. Shouldn't mainArray become the new array created by $.grep?

    Read the article

  • Regarding grep in solaris

    - by Arav
    I want grep for a particular work in multiple files. Multiple files are stored in variable testing. TESTING=$(ls -tr *.txt) echo $TESTING test.txt ab.txt bc.txt grep "word" "$TESTING" grep: can't open test.txt ab.txt bc.txt Giving me an error. Is there any other way to do it other than for loop

    Read the article

  • How to get Bash shell history range

    - by Aniti
    How can I get/filter history entries in a specific range? I have a large history file and frequently use history | grep somecommand Now, my memory is pretty bad and I also want to see what else I did around the time I entered the command. For now I do this: get match, say 4992 somecommand, then I do history | grep 49[0-9][0-9] this is usually good enough, but I would much rather do it more precisely, that is see commands from 4972 to 5012, that is 20 commands before and 20 after. I am wondering if there is an easier way? I suspect, a custom script is in order, but perhaps someone else has done something similar before.

    Read the article

  • Best way to parse this particular string using awk / sed?

    - by Jack
    Hi, I need to get a particular version string from a file (call it version.lst) and use it to compare another in a shell script. For example sake, the file contains lines that look like this: V1.000 -- build date and other info here -- APP1 V1.000 -- build date and other info here -- APP2 V1.500 -- build date and other info here -- APP3 .. and so on. Let's say I am trying to grab the first version (in this case, V1.000) from APP1. Obviously, the versions can change and I want this to be dynamic. What I have right now works: var = `cat version.lst | grep " -- APP1" | grep -Eo V[0-9].[0-9]{3}` Pipe to grep will get the line containing APP1 and the second pipe to grep will get the version string. However, I hear grep is not the way to do this so I'd like to learn the best way using awk or sed. Any ideas? I am new to both and haven't found a tutorial easy enough to learn the syntax of it. Do they support egrep? Thanks!

    Read the article

  • Under *nix, how can I find a string within a file within a directory ?

    - by roberto
    Hi all. I'm using ubuntu linux, and I use bash from with a terminal emulator every day for many tasks. I would like to know how to find a string or a substring within a file that is within a particular directory. If I was knew the file which contained my target substring, I would just cat the file and pipe it through grep, thus: cat file | grep mysubstring But in this case, the pesky substring could be anywhere within a known directory. How do I hunt down my substring ?

    Read the article

  • grep options (unix)

    - by lego69
    hello everyone, can You explain please, can grep pick rows if at least one element from the list appeared, for exmaple grep "hello world" file1 grep must give me all rows which have or word hello or world or both of them, thanks in advance

    Read the article

  • efficientcy effort: grep with a vectored pattern or match with a list of values

    - by Elad663
    I guess this is trivial, I apologize, I couldn't find how to do it. I am trying to abstain from a loop, so I am trying to vectorize the process: I need to do something like grep, but where the pattern is a vector. Another option is a match, where the value is not only the first location. For example data (which is not how the real data is, otherswise I would exploit it structure): COUNTRIES=c("Austria","Belgium","Denmark","France","Germany", "Ireland","Italy","Luxembourg","Netherlands", "Portugal","Sweden","Spain","Finland","United Kingdom") COUNTRIES_Target=rep(COUNTRIES,times=4066) COUNTRIES_Origin=rep(COUNTRIES,each=4066) Now, currently I got a loop that: var_pointer=list() for (i in 1:length(COUNTRIES_Origin)) { var_pointer[[i]]=which(COUNTRIES_Origin[i]==COUNTRS_Target) } The problem with match is that match(x=COUNTRIES_Origin,table=COUNTRIES_Target) returns a vector of the same length as COUNTRIES_Origin and the value is the first match, while I need all of them. The issue with grep is that grep(pattern=COUNTRIES_Origin,x=COUNTRIES_Target) is the given warning: Warning message: In grep(pattern = COUNTRIES_Origin, x = COUNTRIES_Target) : argument 'pattern' has length > 1 and only the first element will be used Any suggestions?

    Read the article

  • On checking kernel parms HP-UX & Oracle 10.2

    - by [email protected]
    Hi,Just did this little script for a customer wanting to investigate if the kernel parameters of their HP-UX machines fits or not the Oracle 10.2 specifications ( looks like someone checked the "User Verified" at database installation time on some prerequisites)Just want to share ( its in Spanish)Hope it helps!--L Normal 0 21 false false false MicrosoftInternetExplorer4 /* Style Definitions */ table.MsoNormalTable {mso-style-name:"Table Normal"; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-parent:""; mso-padding-alt:0cm 5.4pt 0cm 5.4pt; mso-para-margin:0cm; mso-para-margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:10.0pt; font-family:"Times New Roman"; mso-ansi-language:#0400; mso-fareast-language:#0400; mso-bidi-language:#0400;} ### ### check_kernel_parms.sh ### ### ### ###    NAME ###      check_kernel_parms.sh ### ###    DESCRIPTION ###      Comprueba los parametros de kernel ### ###    NOTES ###     Valido para versiones de SO HP-UX y Oracle 10.2 ###     ### ###    MODIFIED   (MM/DD/YY) ###    lvelasco    05/20/10 - Creacion     V_DATE=`/usr/bin/date +%Y%m%d_%H%M%S` if [ "${1}" != 'sin_traza' ]; then   V_FICHERO_LOG=`dirname $0`/`basename $0`.${V_DATE}.log   exec 4>&1   tee ${V_FICHERO_LOG} >&4 |&   exec 1>&p 2>&1 fi   echo "${V_DATE}- check_params.sh *******************************************" echo "Comenzado ejecucion de chequeo de parametros de kernel en maquina `hostname`" echo "****************************************************************************"   UX_VERS=`uname -a | awk '{print $3}'` KCTUNE=/usr/sbin/kctune MEM_TOTAL_MB=`./check_mem` <-- This should return the physical mem of the machine on bytes MEM_TOTAL=$((MEM_TOTAL_MB*1024))     NPROC=$(${KCTUNE} | grep nproc | grep -v '(nproc' | grep -v *nproc | awk '{print $2}') if [ ${NPROC} -lt 4096 ] then        echo "[FAILED] Information: El parametro nproc con valor actual ${NPROC} debe tener una valor superior a 4096" else        echo "[OK] Information: El parametro nproc con valor actual ${NPROC} debe tener una valor superior a 4096" fi     KSI_ALLOC_MAX_T=$(${KCTUNE} | grep ksi_alloc | awk '{print $2}') KSI_ALLOC_MAX=$((NPROC*8)) if [ ${KSI_ALLOC_MAX_T} -lt ${KSI_ALLOC_MAX} ] then        echo "[FAILED] Information: El parametro ksi_alloc_max con valor actual ${KSI_ALLOC_MAX_T} debe tener una valor superior a ${KSI_ALLOC_MAX}" else        echo "[OK] Information: El parametro ksi_alloc_max con valor actual ${KSI_ALLOC_MAX_T} debe tener una valor superior a ${KSI_ALLOC_MAX}" fi       EXECUTABLE_STACK=$(${KCTUNE} | grep executable_stack | awk '{print $2}') if [ ${EXECUTABLE_STACK} -ne 0 ] then        echo "[FAILED] Information: El parametro executable_stack con valor actual ${EXECUTABLE_STACK} debe tener una valor igual a 0" else        echo "[OK] Information: El parametro executable_stack con valor actual ${EXECUTABLE_STACK} debe tener una valor igual a 0" fi       MAX_THREAD_PROC=$(${KCTUNE} | grep max_thread_proc | awk '{print $2}') if [ ${MAX_THREAD_PROC} -lt 1024 ] then        echo "[FAILED] Information: El parametro max_thread_proc con valor actual ${MAX_THREAD_PROC} debe tener una valor superior a 1024" else        echo "[OK] Information: El parametro max_thread_proc con valor actual ${MAX_THREAD_PROC} debe tener una valor superior a 1024" fi     MAXDSIZ=$(${KCTUNE} | grep 'maxdsiz ' | awk '{print $2}') if [ ${MAXDSIZ} -lt 1073741824 ] then        echo "[FAILED] Information: El parametro maxdsiz con valor actual ${MAXDSIZ} debe tener una valor superior a 1073741824" else        echo "[OK] Information: El parametro maxdsiz con valor actual ${MAXDSIZ} debe tener una valor superior a 1073741824" fi     MAXDSIZ_64BIT=$(${KCTUNE} | grep maxdsiz_64bit | awk '{print $2}') if [ ${MAXDSIZ} -lt 2147483648 ] then        echo "[FAILED] Information: El parametro maxdsiz_64bit con valor actual ${MAXDSIZ_64BIT} debe tener una valor superior a 2147483648" else        echo "[OK] Information: El parametro maxdsiz_64bit con valor actual ${MAXDSIZ_64BIT} debe tener una valor superior a 2147483648" fi   MAXSSIZ=$(${KCTUNE} | grep 'maxssiz ' | awk '{print $2}') if [ ${MAXSSIZ} -lt 134217728 ] then        echo "[FAILED] Information: El parametro maxssiz con valor actual ${MAXSSIZ} debe tener una valor superior a 134217728" else        echo "[OK] Information: El parametro maxssiz con valor actual ${MAXSSIZ} debe tener una valor superior a 134217728" fi     MAXSSIZ_64BIT=$(${KCTUNE} | grep maxssiz_64bit | awk '{print $2}') if [ ${MAXSSIZ} -lt 1073741824 ] then        echo "[FAILED] Information: El parametro maxssiz_64bit con valor actual ${MAXSSIZ} debe tener una valor superior a 1073741824" else        echo "[OK] Information: El parametro maxssiz_64bit con valor actual ${MAXSSIZ} debe tener una valor superior a 1073741824" fi     MAXUPRC_T=$(${KCTUNE} | grep maxuprc | awk '{print $2}') MAXUPRC=$(((NPROC*9)/10)) if [ ${MAXUPRC_T} -lt ${MAXUPRC} ] then        echo "[FAILED] Information: El parametro maxuprc con valor actual ${MAXUPRC_T} debe tener una valor superior a ${MAXUPRC}" else        echo "[OK] Information: El parametro maxuprc con valor actual ${MAXUPRC_T} debe tener una valor superior a ${MAXUPRC}" fi   MSGMNI=$(${KCTUNE} | grep msgmni | awk '{print $2}') if [ ${MSGMNI} -lt ${NPROC} ] then        echo "[FAILED] Information: El parametro msgni con valor actual ${MSGMNI} debe tener una valor superior a ${NPROC}" else        echo "[OK] Information: El parametro msgni con valor actual ${MSGMNI} debe tener una valor superior a ${NPROC}" fi     if [ ${UX_VERS} = "B.11.23" ] then        MSGSEG=$(${KCTUNE} | grep msgseg | awk '{print $2}')        if [ ${MSGSEG} -lt 32767 ]        then        echo "[FAILED] Information: El parametro msgseg con valor actual ${MSGSEG} debe tener una valor superior a 32767"        else        echo "[OK] Information: El parametro msgseg con valor actual ${MSGSEG} debe tener una valor superior a 32767"        fi fi   MSGTQL=$(${KCTUNE} | grep msgtql | awk '{print $2}') if [ ${MSGTQL} -lt ${NPROC} ] then        echo "[FAILED] Information: El parametro msgtql con valor actual ${MSGTQL} debe tener una valor superior a ${NPROC}" else        echo "[OK] Information: El parametro msgtql con valor actual ${MSGTQL} debe tener una valor superior a ${NPROC}" fi       if [ ${UX_VERS} = "B.11.23" ] then        NFILE_T=$(${KCTUNE} | grep nfile | awk '{print $2}')        NFILE=$((15*NPROC+2048))        if [ ${NFILE_T} -lt ${NFILE} ]        then        echo "[FAILED] Information: El parametro nfile con valor actual ${NFILE_T} debe tener una valor superior a ${NFILE}"        else        echo "[OK] Information: El parametro nfile con valor actual ${NFILE_T} debe tener una valor superior a ${NFILE}"        fi fi     NFLOCKS=$(${KCTUNE} | grep nflocks | awk '{print $2}') if [ ${NFLOCKS} -lt ${NPROC} ] then        echo "[FAILED] Information: El parametro nflocks con valor actual ${NFLOCKS} debe tener una valor superior a ${NPROC}" else        echo "[OK] Information: El parametro nflocks con valor actual ${NFLOCKS} debe tener una valor superior a ${NPROC}" fi   NINODE_T=$(${KCTUNE} | grep ninode | grep -v vx | awk '{print $2}') NINODE=$((8*NPROC+2048)) if [ ${NINODE_T} -lt ${NINODE} ] then        echo "[FAILED] Information: El parametro ninode con valor actual ${NINODE_T} debe tener una valor superior a ${NINODE}" else        echo "[OK] Information: El parametro ninode con valor actual ${NINODE_T} debe tener una valor superior a ${NINODE}" fi     NCSIZE_T=$(${KCTUNE} | grep ncsize | awk '{print $2}') NCSIZE=$((NINODE+1024)) if [ ${NCSIZE_T} -lt ${NCSIZE} ] then        echo "[FAILED] Information: El parametro ncsize con valor actual ${NCSIZE_T} debe tener una valor superior a ${NCSIZE}" else        echo "[OK] Information: El parametro ncsize con valor actual ${NCSIZE_T} debe tener una valor superior a ${NCSIZE}" fi     if [ ${UX_VERS} = "B.11.23" ] then        MSGMAP_T=$(${KCTUNE} | grep msgmap | awk '{print $2}')        MSGMAP=$((MSGTQL+2))        if [ ${MSGMAP_T} -lt ${MSGMAP} ]        then        echo "[FAILED] Information: El parametro msgmap con valor actual ${MSGMAP_T} debe tener una valor superior a ${MSGMAP}"        else        echo "[OK] Information: El parametro msgmap con valor actual ${MSGMAP_T} debe tener una valor superior a ${MSGMAP}"        fi fi   NKTHREAD_T=$(${KCTUNE} | grep nkthread | awk '{print $2}') NKTHREAD=$((((NPROC*7)/4)+16)) if [ ${NKTHREAD_T} -lt ${NKTHREAD} ] then        echo "[FAILED] Information: El parametro nkthread con valor actual ${NKTHREAD_T} debe tener una valor superior a ${NKTHREAD}" else        echo "[OK] Information: El parametro nkthread con valor actual ${NKTHREAD_T} debe tener una valor superior a ${NKTHREAD}" fi     SEMMNI=$(${KCTUNE} | grep semmni | grep -v '(semm' | awk '{print $2}') if [ ${SEMMNI} -lt ${NPROC} ] then        echo "[FAILED] Information: El parametro semmni con valor actual ${SEMMNI} debe tener una valor superior a ${NPROC}" else        echo "[OK] Information: El parametro semmni con valor actual ${SEMMNI} debe tener una valor superior a ${NPROC}" fi     SEMMNS_T=$(${KCTUNE} | grep semmns | awk '{print $2}') SEMMNS=$((SEMMNI+2)) if [ ${SEMMNS_T} -lt ${SEMMNI} ] then        echo "[FAILED] Information: El parametro semmns con valor actual ${SEMMNS_T} debe tener una valor superior a ${SEMMNS}" else        echo "[OK] Information: El parametro semmns con valor actual ${SEMMNS_T} debe tener una valor superior a ${SEMMNS}" fi   SEMMNU_T=$(${KCTUNE} | grep semmnu | awk '{print $2}') SEMMNU=$((NPROC-4)) if [ ${SEMMNU_T} -lt ${SEMMNU} ] then        echo "[FAILED] Information: El parametro semmnu con valor actual ${SEMMNU_T} debe tener una valor superior a ${SEMMNU}" else        echo "[OK] Information: El parametro semmnu con valor actual ${SEMMNU_T} debe tener una valor superior a ${SEMMNU}" fi     if [ ${UX_VERS} = "B.11.23" ] then        SEMVMX=$(${KCTUNE} | grep msgseg | awk '{print $2}')        if [ ${SEMVMX} -lt 32767 ]        then        echo "[FAILED] Information: El parametro semvmx con valor actual ${SEMVMX} debe tener una valor superior a 32767"        else        echo "[OK] Information: El parametro semvmx con valor actual ${SEMVMX} debe tener una valor superior a 32767"        fi fi     SHMMNI=$(${KCTUNE} | grep shmmni | awk '{print $2}') if [ ${SHMMNI} -lt 512 ] then        echo "[FAILED] Information: El parametro shmmni con valor actual ${SHMMNI} debe tener una valor superior a 512" else        echo "[OK] Information: El parametro shmmni con valor actual ${SHMMNI} debe tener una valor superior a 512" fi     SHMSEG=$(${KCTUNE} | grep shmseg | awk '{print $2}') if [ ${SHMSEG} -lt 120 ] then        echo "[FAILED] Information: El parametro shmseg con valor actual ${SHMSEG} debe tener una valor superior a 120" else        echo "[OK] Information: El parametro shmseg con valor actual ${SHMSEG} debe tener una valor superior a 120" fi   VPS_CEILING=$(${KCTUNE} | grep vps_ceiling | awk '{print $2}') if [ ${VPS_CEILING} -lt 64 ] then        echo "[FAILED] Information: El parametro vps_ceiling con valor actual ${VPS_CEILING} debe tener una valor superior a 64" else        echo "[OK] Information: El parametro vps_ceiling con valor actual ${VPS_CEILING} debe tener una valor superior a 64" fi   SHMMAX=$(${KCTUNE} | grep shmmax | awk '{print $2}') if [ ${SHMMAX} -lt ${MEM_TOTAL} ] then         echo "[FAILED] Information: El parametro shmmax con valor actual ${SHMMAX} debe tener una valor superior a ${MEM_TOTAL}" else         echo "[OK] Information: El parametro shmmax con valor actual ${SHMMAX} debe tener una valor superior a ${MEM_TOTAL}" fi exit 0  

    Read the article

  • puppet master --compile logs errors to stdout

    - by danny
    I see a bug about this that was accepted and then closed a year ago: http://projects.puppetlabs.com/issues/3670 but I'm using puppet 2.7.14 and am getting the same issue. I'm trying to use "puppet solo" (i.e. just running puppet apply on each server to be configured) as I only have 2 or 3 servers in this project and adding another server as a puppetmaster would be completely overkill. Unless I'm mistaken, the best way to apply a node manually to a server is to do: puppet master --compile=mynode > catalog.json puppet apply --catalog catalog.json But the puppet master command outputs a couple of warnings and notices to stdout, mixed in with the desired json content. And it uses colored output so I can't just pipe it through egrep -v '^warning:' EDIT: I guess it's not too big of a deal to use grep - since puppet 2.7 pretty-prints the actual content and the warnings don't ever start with spaces, piping the output through egrep '^( |{|})' works So my questions are basically: Is there a better way than this to apply a puppet node without using a puppetmaster? I can't really find any good references online to using puppet without a puppetmaster, even though that seems like a perfectly reasonable thing to do for a small project. Is there a setting or flag that I'm missing that will get puppet master to stop being an asshole and send its errors to stderr instead of stdout? Or do I really have to turn off color logging, then grep to exclude warning: and notice: lines?

    Read the article

  • How to search file for matching whole lines?

    - by WilliamKF
    I have a command which sends to stdout a series of numbers, each on a new line. I need to determine whether a particular number exists in the list. The match needs to be exact, not a subset. For example, a simple way to approach this that does not work would be to do: /run/command/outputing/numbers | grep -c <numberToSearch> My this gives a false positive on the following list when searching for '456': 1234567 98765 23 1771 If the count is non-zero, a match was found or if it was zero, the number is not in the list. The issue with this is that the numberToSearch could match a subsequence of numbers on a line, instead I only want hits on the whole line. I looked at the man page for grep and did not see any way to only match whole lines. Is there a way to do this, or would I be better off using awk or sed or some other tool instead? I need a binary answer as to whether the number being search for is present or not.

    Read the article

  • grin, ack and rak comparison

    - by sumek
    Having used ack for some time now, I find it much better for my development purposes than grep. But then I've heard about rak and grin. Has anyone used all three of them and can provide a comparison?

    Read the article

  • How to add a variable into a grep command

    - by twigg
    I'm running the following grep command var=`grep -n "keyword" /var/www/test/testfile.txt` This work just as expected but I need to insert the file name dynamically from a loop like so: var=`grep -n "keyword" /var/www/test/`basename ${hd[$i]}`.txt` But obviously the use of ` brakes this with a unexpected EOF while looking for matching ``' and unexpected end of file Any ideas of away around this?

    Read the article

  • How to remove a tagged block of text in a file?

    - by EmpireJones
    How can I remove all instances of tagged blocks of text in a file with sed, grep, or another program? If I have a file which contains: random text // START TEXT internal text // END TEXT more random // START TEXT asdf // END TEXT text how can I remove all blocks of text within the start/end lines, produce the following? random text more random text

    Read the article

  • UNIX tool to dump a selection of HTML?

    - by jldugger
    I'm looking to monitor changes on websites and my current approach is being defeated by a rotating top banner. Is there a UNIX tool that takes a selection parameter (id attribute or XPath), reads HTML from stdin and prints to stdout the subtree based on the selection? For example, given an html document I want to filter out everything but the subtree of the element with id="content". Basically, I'm looking for the simplest HTML/XML equivalent to grep.

    Read the article

  • "watching" a log on FreeBSD vs Linux

    - by Cory J
    On Linux systems I can watch -n1 tail /var/log/whatever.log or watch -n1 grep somestuff /var/log/whatever.log To show updates to a log every 1 seconds. On FreeBSD however, the watch command does something else entirely. Who knows a good FreeBSD command for what I'm trying to do? =)

    Read the article

  • sed or grep or awk to match very very long lines

    - by yael
    more file param1=" 1,deerfntjefnerjfntrjgntrjnvgrvgrtbvggfrjbntr*rfr4fv*frfftrjgtrignmtignmtyightygjn 2,3,4,5,6,7,8, rfcmckmfdkckemdio8u548384omxc,mor0ckofcmineucfhcbdjcnedjcnywedpeodl40fcrcmkedmrikmckffmcrffmrfrifmtrifmrifvysdfn" need to match the content of $param1 in the file but its not work for example sed -n "/$param1/p" file or any grep $param1 file etc... any other solutions? maybe with perl?

    Read the article

  • linux output show only right of ':'

    - by acidzombie24
    I forgot a lot of my command line. I am doing cat file | grep "error" and i would like it to show everything to the right of G:/ including G:/ if possible. I figure its an awk command but i dont know what. I tried awk '{print $8+}' but + does not work like i hoped and guessed.

    Read the article

  • shell scripting: search/replace & check file exist

    - by johndashen
    I have a perl script (or any executable) E which will take a file foo.xml and write a file foo.txt. I use a Beowulf cluster to run E for a large number of XML files, but I'd like to write a simple job server script in shell (bash) which doesn't overwrite existing txt files. I'm currently doing something like #!/bin/sh PATTERN="[A-Z]*0[1-2][a-j]"; # this matches foo in all cases todo=`ls *.xml | grep $PATTERN -o`; isdone=`ls *.txt | grep $PATTERN -o`; whatsleft=todo - isdone; # what's the unix magic? #tack on the .xml prefix with sed or something #and then call the job server; jobserve E "$whatsleft"; and then I don't know how to get the difference between $todo and $isdone. I'd prefer using sort/uniq to something like a for loop with grep inside, but I'm not sure how to do it (pipes? temporary files?) As a bonus question, is there a way to do lookahead search in bash grep? To clarify: so the simplest way to do what i'm asking is (in pseudocode) for i in `/bin/ls *.xml` do replace xml suffix with txt if [that file exists] add to whatsleft list end done

    Read the article

  • How to replace custom IDs in the order of their appearance with a shell script?

    - by Péter Török
    I have a pair of rather large log files with very similar content, except that some identifiers are different between the two. A couple of examples: UnifiedClassLoader3@19518cc | UnifiedClassLoader3@d0357a JBossRMIClassLoader@13c2d7f | JBossRMIClassLoader@191777e That is, wherever the first file contains UnifiedClassLoader3@19518cc, the second contains UnifiedClassLoader3@d0357a, and so on. I want to replace these with identical IDs so that I can spot the really important differences between the two files. I.e. I want to replace all occurrences of both UnifiedClassLoader3@19518cc in file1 and UnifiedClassLoader3@d0357a in file2 with UnifiedClassLoader3@1; all occurrences of both JBossRMIClassLoader@13c2d7f in file1 and JBossRMIClassLoader@191777e in file2 with JBossRMIClassLoader@2 etc. Using the Cygwin shell, so far I managed to list all different identifiers occurring in one of the files with grep -o -e 'ClassLoader[0-9]*@[0-9a-f][0-9a-f]*' file1.log | sort | uniq However, now the original order is lost, so I don't know which is the pair of which ID in the other file. With grep -n I can get the line number, so the sort would preserve the order of appearance, but then I can't weed out the duplicate occurrences. Unfortunately grep can not print only the first match of a pattern. I figured I could save the list of identifiers produced by the above command into a file, then iterate over the patterns in the file with grep -n | head -n 1, concatenate the results and sort them again. The result would be something like 2 ClassLoader3@19518cc 137 ClassLoader@13c2d7f 563 ClassLoader3@1267649 ... Then I could (either manually or with sed itself) massage this into a sed command like sed -e 's/ClassLoader3@19518cc/ClassLoader3@2/g' -e 's/ClassLoader@13c2d7f/ClassLoader@137/g' -e 's/ClassLoader3@1267649/ClassLoader3@563/g' file1.log > file1_processed.log and similarly for file2. However, before I start, I would like to verify that my plan is the simplest possible working solution to this. Is there any flaw in this approach? Is there a simpler way?

    Read the article

< Previous Page | 5 6 7 8 9 10 11 12 13 14 15 16  | Next Page >