Sponsored Content
Top Forums UNIX for Dummies Questions & Answers awk: syntax for "if (array doesn't contain a particular index)" Post 302704039 by beca123456 on Friday 21st of September 2012 09:29:00 PM
Old 09-21-2012
Thanks agama, it is more clear to me now!Smilie

But, how could I do if I would need a track of the output I got after converting number to letters, but need to keep going in my script using this ouptut (the track I produced just before) as an input for the rest of the script.

I know how to output from the script, but I don't know how to input a new file from the script.
Is it doable with awk?

I tried several variants of that but it didn't work:
Code:
BEGIN {
        xtab["11"]="a";
        xtab["12"]="b";
        xtab["13"]="c";
    }
  
    # accepts word and starting offset 
    function xlate( w, start)
    {
        xw = ""
        n = substr(w, start, 2) 
        while( n != "" )
        {
            xw = xw (n in xtab ? xtab[n] : "X")
            start = start + 2;
            n = substr(w, start, 2)
        }
        return xw
    }
     { 
         for(i=1; i<=2; 1 +=2)
             print xlate($1, i) > "track.txt"         # I can keep a track like that
     }
     {
         while(0< (getline < "track.test")          # I don't know how to input a different file from the one I used originally
             do the rest of my script
                 ...
     }

---------- Post updated 21-09-12 at 08:29 PM ---------- Previous update was 20-09-12 at 09:24 PM ----------

Help please !!!Smilie
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Awk Syntax Error "!~"

This is my Awk command. direct_count=`awk -F; 'BEGIN { direct_count=0 } $16 !~ /(PBLON|PBNY)/ || $18 !~ /(PBLON|PBNY)/ { direct_count++ } END { print direct_count }' ls.txt` I get a syntax error. BEGIN { direct_count=0 } $16 !~ /(PBLON|PBNY)/ || $18 !~ /(PBLON|PBNY)/ { direct_count++ }... (6 Replies)
Discussion started by: yongho
6 Replies

2. UNIX for Dummies Questions & Answers

Explain the line "mn_code=`env|grep "..mn"|awk -F"=" '{print $2}'`"

Hi Friends, Can any of you explain me about the below line of code? mn_code=`env|grep "..mn"|awk -F"=" '{print $2}'` Im not able to understand, what exactly it is doing :confused: Any help would be useful for me. Lokesha (4 Replies)
Discussion started by: Lokesha
4 Replies

3. Shell Programming and Scripting

acessing awk array element while getline < "file"

I am attempting to write a awk script that reads in a file after awk array elements are assigned and using those elements while reading in the new file. Does this make sense? /pattern/ {tst=$3} (( getline < "file" ) > 0 ) { x=x " "tst } When I print tst in the END statement it... (9 Replies)
Discussion started by: timj123
9 Replies

4. Shell Programming and Scripting

awk array starting with "ord"

I was writing a awk function and had a error I was wondering about. It revolves around a Multidimensional array starting with ord example: if ( _e == 5 ) { lmrb=$5 ; lmtb=$6 ; larb=$7 ; latb=$8 } ... (2 Replies)
Discussion started by: timj123
2 Replies

5. Shell Programming and Scripting

cat $como_file | awk /^~/'{print $1","$2","$3","$4}' | sed -e 's/~//g'

hi All, cat file_name | awk /^~/'{print $1","$2","$3","$4}' | sed -e 's/~//g' Can this be done by using sed or awk alone (4 Replies)
Discussion started by: harshakusam
4 Replies

6. Shell Programming and Scripting

Need to parse file "x" lines at a time ... awk array?

I have files that store multiple data points for the same device "vertically" and include multiple devices. It repeats a consistant pattern of lines where for each line: Column 1 is a common number for the entire file and all devices in that file Column 2 is a unique device number Column 3 is... (7 Replies)
Discussion started by: STN
7 Replies

7. Programming

C: Initialize "const" array from the "heap"

Hello, I am working on solving an NP-Complete problem, so it is very important that operations and data with limited integer-argument ranges be computed using immutable look-up-tables contained entirely in CPU cache. Retrieval of the look-up-table data must never leave the CPU once initially... (6 Replies)
Discussion started by: HeavyJ
6 Replies

8. Shell Programming and Scripting

awk command to replace ";" with "|" and ""|" at diferent places in line of file

Hi, I have line in input file as below: 3G_CENTRAL;INDONESIA_(M)_TELKOMSEL;SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL My expected output for line in the file must be : "1-Radon1-cMOC_deg"|"LDIndex"|"3G_CENTRAL|INDONESIA_(M)_TELKOMSEL"|LAST|"SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL" Can someone... (7 Replies)
Discussion started by: shis100
7 Replies

9. HP-UX

DLT 7000 tape drive failing with "write error on a record in the index"

HP rp5450 (L2000) running HP-UX 11.11B Using DLT 7000 and DLT 4000 tape drives for nightly full backups Backup jobs created by SAM DLT 7000 cron entry is as follows: 00 2 * * 1-6 /usr/sam/lbin/br_backup DLT FULL Y /dev/rmt/0m /var/sam/graphLCAa17036 root Y 1 N > /var/sam/SAM_br_msgs 2>&1... (1 Reply)
Discussion started by: dreh99
1 Replies

10. Shell Programming and Scripting

how to use "cut" or "awk" or "sed" to remove a string

logs: "/home/abc/public_html/index.php" "/home/abc/public_html/index.php" "/home/xyz/public_html/index.php" "/home/xyz/public_html/index.php" "/home/xyz/public_html/index.php" how to use "cut" or "awk" or "sed" to get the following result: abc abc xyz xyz xyz (8 Replies)
Discussion started by: timmywong
8 Replies
exportfs(8)						      System Manager's Manual						       exportfs(8)

NAME
exportfs - maintain list of NFS exported file systems SYNOPSIS
/usr/sbin/exportfs [-avi] [-o options,..] [client:/path ..] /usr/sbin/exportfs -r [-v] /usr/sbin/exportfs [-av] -u [client:/path ..] /usr/sbin/exportfs [-v] DESCRIPTION
The exportfs command is used to maintain the current table of exported file systems for NFS. This list is kept in a separate file named /var/lib/nfs/xtab which is read by mountd when a remote host requests access to mount a file tree, and parts of the list which are active are kept in the kernel's export table. Normally this xtab file is initialized with the list of all file systems named in /etc/exports by invoking exportfs -a. However, administrators can choose to add and delete individual file systems without modifying /etc/exports using exportfs. Any export requests which identify a specific host (rather than a subnet or netgroup etc) are entered directly into the kernel's export ta- ble as well as being written to /var/lib/nfs/xtab. Further, any mount points listed in /var/lib/nfs/rmtab which match a non host-specific export request will cause an appropriate export entry for the host given in rmtab to be entered into the kernel's export table. OPTIONS
-a Export or unexport all directories. -o options,... Specify a list of export options in the same manner as in exports(5). -i Ignore the /etc/exports file, so that only default options and options given on the command line are used. -r Reexport all directories. It synchronizes /var/lib/nfs/xtab with /etc/exports. It removes entries in /var/lib/nfs/xtab which are deleted from /etc/exports, and remove any entries from the kernel export table which are no longer valid. -u Unexport one or more directories. -v Be verbose. When exporting or unexporting, show what's going on. When displaying the current export list, also display the list of export options. DISCUSSION
Exporting Directories The first synopsis shows how to invoke the command when adding new entries to the export table. When using exportfs -a, all directories in exports(5) are added to xtab and the resulting list is pushed into the kernel. The host:/path argument specifies the directory to export along with the host or hosts to export it to. All formats described in exports(5) are supported; to export a directory to the world, simply specify :/path. The export options for a particular host/directory pair derive from several sources. There is a set of default options which can be over- ridden by entries in /etc/exports (unless the -i option is given). In addition, the administrator may overide any options from these sources using the -o argument which takes a comma-separated list of options in the same fashion as one would specify them in exports(5). Thus, exportfs can also be used to modify the export options of an already exported directory. Modifications of the kernel export table used by nfsd(8) take place immediately after parsing the command line and updating the xtab file. The default export options are sync,ro,root_squash,no_delay. Unexporting Directories The third synopsis shows how to unexported a currently exported directory. When using exportfs -ua, all entries listed in xtab are removed from the kernel export tables, and the file is cleared. This effectively shuts down all NFS activity. To remove individial export entries, one can specify a host:/path pair. This deletes the specified entry from xtab and removes the corre- sponding kernel entry (if any). Dumping the Export Table Invoking exportfs without further options shows the current list of exported file systems. When giving the -v option, the list of flags pertaining to each export are shown in addition. EXAMPLES
The following adds all directories listed in /etc/exports to /var/lib/nfs/xtab and pushes the resulting export entries into the kernel: # exportfs -a To export the /usr/tmp directory to host djando, allowing asynchronous writes, one would do this: # exportfs -o async django:/usr/tmp DEPENDENCIES
Exporting to IP networks, DNS and NIS domains does not enable clients from these groups to access NFS immediately; rather, these sorts of exports are hints to mountd(8) to grant any mount requests from these clients. This is usually not a big problem, because any existing mounts are preserved in rmtab across reboots. When unexporting a network or domain entry, any current exports to members of this group will be checked against the remaining valid exports and if they themselves are nolonger valid they will be removed. SEE ALSO
exports(5), mountd(8) AUTHORS
Olaf Kirch, <okir@monad.swb.de> Neil Brown, <neilb@cse.unsw.edu.au> 7 Sep 1999 exportfs(8)
All times are GMT -4. The time now is 09:09 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy