Search Results

Search found 490 results on 20 pages for 'awk'.

Page 5/20 | < Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • Format a timestamp into text

    - by user1257114
    I want to get the Modify date of a file and then format it into a human readable date. I am running a C program that gets information on when a particular file was last modified. My C Code contains a sytem cmd which contains a number of egreps, awks, seds separated by pipes. Using sed or awk or something similar, how can I convert 06 to June (This can be any month so an array or something is required) What I am trying to achieve is to end up with a string similar to: My C code contains: char string1[100] = ""; #define MAXCHAR 100 FILE *fp; char str[MAXCHAR], str2[MAXCHAR]; char* filename = "newfile"; /* stat: run 'stat' on the dtlName file to display status information. egrep: search for the pattern 'Modify' and print the lines containing it. awk: Get columns 2 & 3 sed: replace the . with a space, leaving 3 columns of output awk: only print cols 1 & 2 to newfile sed: replace '-' with ' ' in newfile awk: format output in newfile */ sprintf(string1, "/bin/stat %s \ | egrep Modify \ | /bin/awk '{print $2, $3}' \ | /bin/sed 's/\\./ /g' \ | /bin/awk '{print $1, $2}' \ | /bin/sed 's/-/ /g' \ | /bin/awk '{print $3,$2\", \"$1,\"at\",$4}' > newfile" , dtlName); system(string1); fp = fopen(filename, "r"); while (fgets(str, MAXCHAR, fp) != NULL) sprintf(str2,"%s", str); /* Write information to file */ DisplayReportFile (report); ReportEntry (report,L"Source file: %s, Created: %s\n\n",dtlName,str2);

    Read the article

  • Concatenation awk outputs

    - by Rookie_22
    I'm using regex to parse NMAP output. I want the ip addresses which are up with the corresponding ports open. Now I've a very naive method of doing that: awk '/^Scanning .....................ports]/ {print substr ($2,1,15);}' results.txt awk '/^[0-9][0-9]/ {print substr($1,1,4);}' results.txt | awk -f awkcode.awk where awkcode.awk contains the code to extract numbers out of the substring. The first line prints all the ips that are up and 2nd gives me the ports. My problem is that I want them mapped to each other. Is there any way to do that? Even sed script would do.

    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

  • Replacing quotes in a file

    - by Matthijs
    I have a large number of large semicolon-separated data files. All string fields are surrounded by double quotes. In some of the files, there are extra quotes in the string fields, which messes up the subsequent importing of the data for analysis (I'm importing to Stata). This code allows me to see the problematic quotes using gnu-awk: echo '"This";"is";1;"line" of" data";""with";"extra quotes""' | awk 'BEGIN { FPAT = "([^;]+)|(\"[^\"]+\")"}; {for ( i=1 ; i<=NF ; i++ ) if ($i ~ /^"(.*".*)+"$/) {print NR, $i}}' 1 "line" of" data" 1 ""with" 1 "extra quotes"" but I do not know how to replace them. I was thinking of doing the replace manually, but it turns out that there are several hundred matches in some of the files. I know about awk's -sub-, -gsub-, and -match- functions, but I am not sure how to design a search and replace for this specific problem. In the example above, the respective fields should be "This", "is", 1, "line of data", "with", "extra quotes", that is: all semicolons are separators, and all quotes except for the outermost quotes should be removed. Should I may be use -sed-, or is -awk- the right tool? Hope you can help me out! Thanks, Matthijs

    Read the article

  • How to do a join of 3 files with awk by first Column?

    - by noinflection
    i have three similar files, they are all like this: ID1 Value1a ID2 Value2a . . . IDN Value2n and i want an output like this ID1 Value1a Value1b Value1c ID2 Value2a Value2b Value2c ..... IDN ValueNa ValueNb ValueNc Looking to the first line i want value1A to be the value of id1 in fileA, value1B the value of id1 in fileB, etc, i think of it like a nice sql join. I've tried several things but none of them where even close.

    Read the article

  • Merge two text files at a specific location, sed or awk.

    - by S1syphus
    I have two text files, I want to place a text in the middle of another, I did some research and found information about adding single strings: I have a comment in the second text file called STUFFGOESHERE, so I tried: sed '/^STUFFGOESHERE/a file1.txt' file2.txt sed: 1: "/^STUFFGOESHERE/a long.txt": command a expects \ followed by text So I tried something different, trying to place the contents of the text based on a given line, but no luck. Any ideas?

    Read the article

  • Use Awk to Print every character as its own column?

    - by wizkid84
    Hi there, I am in need of reorganizing a large CSV file. The first column, which is currently a 6 digit number needs to be split up, using comma's as the field separator. For example, I need this: 022250,10:50 AM,274,22,50 022255,11:55 AM,275,22,55 turned into this: 0,2,2,2,5,0,10:50 AM,274,22,50 0,2,2,2,5,5,11:55 AM,275,22,55 Let me know what you think! Thanks!

    Read the article

  • File size limit exceeded in bash

    - by yboren
    I have tried this shell script on a SUSE 10 server, kernel 2.6.16.60, ext3 filesystem the script has problem like this: cat file | awk '{print $1" "$2" "$3}' | sort -n > result the file's size is about 3.2G, and I get such error message: File size limit exceeded in this shell, ulimit -f is unlimited after I change script into this cat file | awk '{print $1" "$2" "$3}' >tmp sort -n tmp > result the problem is gone. I don't know why, can anyone help me with an explanation?

    Read the article

  • How can I quickly parse large (>10GB) files?

    - by Andrew
    Hi - I have to process text files 10-20GB in size of the format: field1 field2 field3 field4 field5 I would like to parse the data from each line of field2 into one of several files; the file this gets pushed into is determined line-by-line by the value in field4. There are 25 different possible values in field2 and hence 25 different files the data can get parsed into. I have tried using Perl (slow) and awk (faster but still slow) - does anyone have any suggestions or pointers toward alternative approaches? FYI here is the awk code I was trying to use; note I had to revert to going through the large file 25 times because I wasn't able to keep 25 files open at once in awk: chromosomes=(1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25) for chr in ${chromosomes[@]} do awk < my_in_file_here -v pat="$chr" '{if ($4 == pat) for (i = $2; i <= $2+52; i++) print i}' >> my_out_file_"$chr".query done

    Read the article

  • cygwin, PATH problem?

    - by jayjaypg22
    I run a .ksh containing a awk call. awk.exe and his shortcut awk is in /bin/awk, /bin is in the PATH environment variable. But when I try to launch awk, I have this error message : bash: /usr/bin/awk: no such file or directory Why didn't bash look for it in the /bin folder too? edit : tar has the same rights, tar.exe is in /bin and can be listed in /usr/bin/, the exact same way than awk. Tar works fine whereas awk not.

    Read the article

  • cygwin, PATH problem?

    - by jayjaypg22
    I run a .ksh containing a awk call. awk.exe and his shortcut awk is in /bin/awk, /bin is in the PATH environment variable. But when I try to launch awk, I have this error message : bash: /usr/bin/awk: no such file or directory Why didn't bash look for it in the /bin folder too? edit : tar has the same rights, tar.exe is in /bin and can be listed in /usr/bin/, the exact same way than awk. Tar works fine whereas awk not.

    Read the article

  • The script not working as expected files dump path

    - by user3319390
    I have a script needs to be dump matching cname from my file contains and then matching scode to dump file to $cname/$year/$month/$day/ into files like access and error logs #!/bin/sh #base_dir="/home/vizion/Desktop" path="/home/vizion/Desktop/adn_DF9D_20140515_0005.log" name=$(basename "$path" ".log") for x in *.log; do year=${x:9:4}; month=${x:13:2}; day=${x:15:2}; done while read -r line do cname=$(echo ${line} | awk '{split($7,c,"/"); print c[3]}') scode=$(echo ${line} | awk -F"[ ]" '{print $9}') [[ ! -d "$cname/$year/$month/$day" ]] && mkdir -p "$cname/$year/$month/$day/" [[ ( ${scode} -ge 200 ) && ( ${scode} -le 399 ) ]] && { # [[ ! -d "$cname/$year/$month/$day" ]] && mkdir -p "$cname/$year/$month/$day/" echo ${line} >> /home/vizion/Desktop/$cname/$year/$month/$day/${cname}_${name}_access.log } [[ ( ${scode} -ge 400 ) && ( ${scode} -le 599 ) ]] && { [[ ! -d "$cname/$year/$month/$day" ]] && mkdir -p "$cname/$year/$month/$day" echo ${line} >> ${cname}_${name}_error.log } done < $path i am able to filter logs but not not dumping the exact location It's going other locations suggest to me correction in script

    Read the article

  • Shell script to block proftp failled attempt

    - by Saif
    Hello, I want to filter and block failed attempt to access my proftp server. Here is an example line from the /var/log/secure file: Jan 2 18:38:25 server1 proftpd[17847]: spy1.XYZ.com (93.218.93.95[93.218.93.95]) - Maximum login attempts (3) exceeded There are several lines like this. I would like to block any attempts like this from any IP twice. Here's a script I'm trying to run to block those IPs. tail -1000 /var/log/secure | awk '/proftpd/ && /Maximum login/ { if (/attempts/) try[$7]++; else try[$11]++; } END { for (h in try) if (try[h] > 4) print h; }' | while read ip do /sbin/iptables -L -n | grep $ip > /dev/null if [ $? -eq 0 ] ; then # echo "already denied ip: [$ip]" ; true else logger -p authpriv.notice "*** Blocking ProFTPD attempt from: $ip" /sbin/iptables -I INPUT -s $ip -j DROP fi done how can I select the IP with "awk". with the current script it's selecting "(93.218.93.95[93.218.93.95])" this line completely. But i only want to select the IP.

    Read the article

  • Parsing the first column of a csv file to a new file.

    - by S1syphus
    Operating System: OSX Method: From the command line, so using sed, cut, gawk, although preferably no installing modules. Essentially I am trying to take the first column of a csv file and parse it to a new file. Example input file EXAMPLEfoo,60,6 EXAMPLEbar,30,6 EXAMPLE1,60,3 EXAMPLE2,120,6 EXAMPLE3,60,6 EXAMPLE4,30,6 Desire output EXAMPLEfoo EXAMPLEbar EXAMPLE1 EXAMPLE2 EXAMPLE3 EXAMPLE4 So I want the first column. Here is what I have tried so far: awk -F"," '{print $1}' in.csv > out.txt awk -F"," '{for (i=2;i<=NF;i++)}' in.csv > out.txt awk -F"," 'BEGIN { OFS="," }' '{print $1}' in.csv > out.txt cat in.csv | cut -d \, -f 1 > out.txt None seem to work, either they just print the first line or nothing at all, so I would assume it's failing to read line by line.

    Read the article

  • I cant really wrap my head around BOOLEAN logic when I use NOT together with AND and OR

    - by Bq
    Im trying to understand how boolean logic works when I use NOT. To give an example using awk I have a text file containing CORE PORT CORE PORT COREPORT CORE COREPORT And I would like to remove all COREPORT lines. The way I thought I would do it was with (NOT CORE) AND (NOT PORT) eg awk '/!CORE/&&/!PORT/{print}' But when I try it out Im actually supposed to use OR instead of AND awk '/!CORE/||/!PORT/{print}' I would be really glad if some one could explain where my thinking is wrong and super glad if it could be visualized with a venn diagram or something like the boolean machine at kathyschrock

    Read the article

  • Running Awk command on a cluster

    - by alex
    How do you execute a Unix shell command (awk script, a pipe etc) on a cluster in parallel (step 1) and collect the results back to a central node (step 2) Hadoop seems to be a huge overkill with its 600k LOC and its performance is terrible (takes minutes just to initialize the job) i don't need shared memory, or - something like MPI/openMP as i dont need to synchronize or share anything, don't need a distributed VM or anything as complex Google's SawZall seems to work only with Google proprietary MapReduce API some distributed shell packages i found failed to compile, but there must be a simple way to run a data-centric batch job on a cluster, something as close as possible to native OS, may be using unix RPC calls i liked rsync simplicity but it seem to update remote notes sequentially, and you cant use it for executing scripts as afar as i know switching to Plan 9 or some other network oriented OS looks like another overkill i'm looking for a simple, distributed way to run awk scripts or similar - as close as possible to data with a minimal initialization overhead, in a nothing-shared, nothing-synchronized fashion Thanks Alex

    Read the article

  • unix command to verify span of word in text

    - by Ocasta Eshu
    What unix command(s) can I use to determine the line span that a word appears in text? The "span" being equal to the line number of the last instance of a word minus the line number of the first instance of the word. 1| unix is on two lines 2| once above, and once below 3| unix In the example above the "span" of 'unix' would be 2 (3-1). So far I've been trying to make use of grep -n but I don't think that grep is powerful enough. Maybe some use of sed or awk? Thanks!

    Read the article

  • Gathering IP's from a complicated log

    - by Harry
    I have a question regarding the use of some more advanced grep, awk, sed. I have a log file, for a proprietary MTA, that contains IP's in a string, delimited by [redacted]^~x.x.x.x^[redacted]. So far all of my grepping, awking, and sedding hasn't gotten me very far. This log file has 331520 lines in it. My goal was to simply grep out the ip's, then do a for loop with sed, to sed 's/$i/redacted'. I'm including a sample of one of the log entries. If you all have any idea, I would be greatly appreciative. Jun 4 15:21:52 host.name mta-name: 13388^~88/CC-04671-FCA0DCF4^~D^~<redactedmessageid>^~@^[email protected]^~redacted.hostname^~000.00.000.000^~port^~esmtp^~^~external_routing_nobounce^~0^~0.51^~subjectofmessage^~250 2.6.0 <redactedmessageid> [InternalId=2178458] Queued mail for delivery

    Read the article

  • How to get the pid of a running process using a single command that parse the output of ps?

    - by Sorin Sbarnea
    I am looking for a single line that does return the pid of a running process. Currently I have: ps -A -o pid,cmd|grep xxx|head -n 1 And this returns the fist pid, command. I need only the first number from the output and ignore the rest. I suppose sed or awk would help here but my experience with them is limited. Also, this has another problem, it will return the pid of grep if the xxx is not running. It's really important to have a single line, as I want to reuse the output for doing something else, like killing that process.

    Read the article

  • Extracting a line section of mysql backup using sed

    - by carpii
    I occasionally need to extract a single record from a mysqlbackup To do this, I first extract the single table I want from the backup... sed -n -e '/CREATE TABLE.*usertext/,/CREATE TABLE/p' 20120930_backup.sql > table.sql In table.sql, the records are batched using extended inserts (with maybe 100 records per insert before it creates a new line starting with INSERT INTO), so they look like... INSERT INTO usertext VALUES (1, field2 etc), (2, field2 etc), INSERT INTO usertext VALUES (101, field2 etc), (102, field2 etc), ... Im trying to extract record 239560 from this, using... sed -n -e '/(239560.*/,/)/p' table.sql > record.sql Ie.. start streaming when it finds 239560, and stop when it hits the closing bracket But this isnt working as I hoped, it just results in the full insert batch being output. Please can someone give me some pointers as to where Im going wrong? Would I be better off using awk for extracting segments of lines, and use sed for extracting lines within a file?

    Read the article

  • linux + match only VALID IP from text file into other file

    - by yael
    please advice how to match only the valid IPs ( 255.255.255.255 ) from the file.txt and insert only the valid IP into VALID_IP.txt file ( see VALID_IP.txt for example ) the solution should be implemented in my ksh script ( so perl or sed or awk is fine also ) more file.txt e32)5.500.5.5*kjcdr ##@$1.1.1.1+++jmjh 1.1.1.1333 33331.1.1.1 @5.5.5.?????? ~3de.ede5.5.5.5 1.1.1.13444r54 192.9.30.174 &&^#%5.5.5.5 :5.5.5.5@%%^^&* :5.5.5.5: **22.22.22.22 172.78.0.1()*5.4.3.277 example of VALID_IP.txt file 1.1.1.1 192.9.30.174 5.5.5.5 5.5.5.5 5.5.5.5 22.22.22.22 172.78.0.1

    Read the article

  • match patterns update output file uncomment when desired

    - by user2692634
    Need suggestion for following. Have two files myfile and responsefile. First file myfile.txt user=myname user_1=yourname group=mygroup group_1=yourgroup second file responsefile.txt #Please fill details user= #user_1= #user_2= #Please fill details group= #group_1= #group_2= Based on myfile.txt data update responsefile.txt as below and the file responsefile.txt is lenghty of about 604L, 16481C. Result output responsefile.txt #Please fill details user=myname user_1=yourname #user_2= #Please fill details group=mygroup group_1=yourgroup #group_2= If you observe myfile above, I want to match user= in responsefile, then update as user=myname, same applies for group=. Then match user_1= and group_1= which is hashed or commented in responsefile, update as user_1=yourname and group_1=yourgroup. Should not remove hash or uncomment for others in file. I tried this awk -F= 'NR==FNR{a[$1]=$0;next}$1 in a{$0=a[$1]}1' myfile.txt responsefile.txt Please suggest thanks in advance.

    Read the article

  • Text after Control Sequence

    - by SPAM SPAM SPAM SPAM
    I am trying to parse the output of a command that expects to be writing to the screen. It has data separated by move-to-origin control sequences (for the VT220, ESC[1;1H). I only need the last part (i.e. after the last move-to-origin). I have tried doing this multiple ways (primarily awk and sed), but the problem is always that parts of the control sequence have special meaning (to the program, not just to the shell), and I cannot quote them when I substitute tput's output. Any suggestions?

    Read the article

< Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >