Sponsored Content
Full Discussion: Write array contents to file
Top Forums Shell Programming and Scripting Write array contents to file Post 302582578 by Corona688 on Friday 16th of December 2011 11:29:52 AM
Old 12-16-2011
No need to use loops or sed to separate an array on newlines. The shell can do this by itself by changing the IFS variable into a newline, letting you print the entire array in a single operation.
Code:
OLDIFS="$IFS"; IFS=$'\n'
        echo "${ARRAY[*]}" > file
IFS="$OLDIFS"

Note that "${ARRAY[*]}" must be in quotes for IFS to have the right effect here.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Can I assign the contents of file into an array?

I am trying to assign the contents of file e.g ls "$HOME" into an array. If it is possible then please guide me without using the concept of awk,sed, and perl16 Thanks (10 Replies)
Discussion started by: murtaza
10 Replies

2. Programming

How to read and write directory or file contents in c++ ?

Dear Friends, I m beginner unix programmer. I want to know, how to read and write directory or file contents in c++ ? (3 Replies)
Discussion started by: namrata5
3 Replies

3. UNIX for Dummies Questions & Answers

compare array contents with file

I have an array "arrA" with the following contents: A0012 Paint Shop.doc ES001 Contract Signature.doc Budget Plan.pdf TS PWS.pdf My data file "Files.dat" has the same contents: A0012 Paint Shop.doc ES001 Contract Signature.doc Budget Plan.pdf TS PWS.pdf I have a script that compares... (0 Replies)
Discussion started by: orahi001
0 Replies

4. Shell Programming and Scripting

Remove spaces from first field, and write entire contents into other text file

Hi all, I have searched and found various threads about removing spaces from a field within a text file. Unfortunately, I have not found exactly what I'm looking for, nor am I adept enough to modify what I've found into what I need. I use the following command to remove the first line... (3 Replies)
Discussion started by: carriehoff
3 Replies

5. Shell Programming and Scripting

PERL - copy fiel contents to array then compare against other file

Basically to illuminate i want to take a file with mutliple lines, C:\searching4theseletters.txt a b c Read this into an array @ARRAY and then use this to compare against another file C:\inputletters.txt b o a c n a (9 Replies)
Discussion started by: bradleykins
9 Replies

6. Shell Programming and Scripting

Most reliable way to store file contents in an array in bash

Hi Guys, I have a file which has numbers in it separated by newlines as follows: 1.113 1.456 0.556 0.021 -0.541 -0.444 I am using the following code to store these in an array in bash: FILE14=data.txt ARRAY14=(`awk '{print}' $FILE14`) (6 Replies)
Discussion started by: npatwardhan
6 Replies

7. Shell Programming and Scripting

Issues using array credentials to read contents of a file

Hi, I am trying to read the contents of a file using array credentials in unix. The file I am trying to read is tab separated and contains the below contents. # partnerid Direc Server Port Source_Dir Target_Dir Mask Remove Files Passwordless Compare Files ... (3 Replies)
Discussion started by: aartikara
3 Replies

8. Shell Programming and Scripting

Place the contents of a .CSV file to an array

Hi, I am trying to place the contents of a .CSV file to an array, but not sure how to do that. Here is my .CSV file content: App,SLA,Job name,Avg start time,Avg run time,Frequency,Downstream apps XYZ,,ABC14345,3:00 AM,00.04.00,Daily,STAMP XYZ,9:00,ABC12345,3:15 AM,00.05.00,Daily,STAMP ... (4 Replies)
Discussion started by: ajayakunuri
4 Replies

9. UNIX for Dummies Questions & Answers

Write terminal contents into a one file in UNIX

Hi guys, How to write terminal contents into a file in Unix operating system Actually I created GUI by using Gtk2-perl. I want to display data on GUI whatever the contents writing on terminal. So which command I have to use and where that command to be run I mean in shell script or Perl... (2 Replies)
Discussion started by: kiran425
2 Replies

10. UNIX for Dummies Questions & Answers

Trying To Write File Contents To Specfic .csv Cell

Hi, I'm attempting to write the entire contents of a file to a specific .csv cell. So far have only a nawk one liner that will write a value into a specific .csv cell. Trying to use man page but can't seem to get any farther. Any help would be appreciated. nawk -v r=2 -v c=3 -v val=5 -F,... (7 Replies)
Discussion started by: jimmyf
7 Replies
dat_lmr_sync_rdma_write(3DAT)			     Direct Access Transport Library Functions			     dat_lmr_sync_rdma_write(3DAT)

NAME
dat_lmr_sync_rdma_write - synchronize local memory with RDMA write on non-coherent memory SYNOPSIS
cc [ flag... ] file... -ldat [ library... ] #include <dat/udat.h> DAT_RETURN dat_lmr_sync_rdma_write ( IN DAT_IA_HANDLE ia_handle, IN const DAT_LMR_TRIPLET *local_segments, IN DAT_VLEN num_segments ) PARAMETERS
ia_handle A handle for an open instance of the IA. local_segments An array of buffer segments. num_segments The number of segments in the local_segments argument. DESCRIPTION
The dat_lmr_sync_rdma_write() function makes effects of an incoming RDMA Write operation visible to the Consumer. This operation guarantees consistency by locally invalidating the non-coherent cache whose buffer has been populated by remote peer RDMA write operations. The dat_lmr_sync_rdma_write() function is needed if and only if the Provider attribute specifies that this operation is needed after an incoming RDMA Write operation. The Consumer must call dat_lmr_sync_rdma_write() before reading data from a memory range in this region that was the target of an incoming RDMA Write operation. The dat_lmr_sync_rdma_write() function must be called after the RDMA Write operation completes, and the memory range that was modified by the RDMA Write must be supplied by the caller in the local_ segments array. After this call returns, the Consumer may safely see the modified contents of the memory range. It is permissible to batch synchronizations of multi- ple RDMA Write operations in a single call by passing a local_segments array that includes all modified memory ranges. The local_segments entries need not contain the same LMR and need not be in the same Protection Zone. The Consumer must also use dat_lmr_sync_rdma_write() when performing local writes to a memory range that was or will be the target of incoming RDMA writes. After performing the local write, the Consumer must call dat_lmr_sync_rdma_write() before the RDMA Write is initi- ated. Conversely, after an RDMA Write completes, the Consumer must call dat_lmr_sync_rdma_write() before performing a local write to the same range. If the Provider attribute specifies that this operation is needed and the Consumer attempts to read from a memory range in an LMR without properly synchronizing using dat_lmr_sync_rdma_write(), the returned contents are undefined. If the Consumer attempts to write to a memory range without properly synchronizing, the contents of the memory range become undefined. RETURN VALUES
DAT_SUCCESS The operation was successful. DAT_INVALID_HANDLE The DAT handle is invalid. DAT_INVALID_PARAMETER One of the parameters is invalid. For example, the address range for a local segment fell outside the boundaries of the corresponding Local Memory Region or the LMR handle was invalid. USAGE
Determining when an RDMA Write completes and determining which memory range was modified is the Consumer's responsibility. One possibility is for the RDMA Write initiator to post a Send DTO message after each RDMA Write that identifies the range in the body of the Send. The Consumer at the target of the RDMA Write can receive the message and know when and how to call dat_lmr_sync_rdma_write(). This call ensures that the Provider receives a coherent view of the buffer contents after a subsequent remote RDMA Write operation. After the call completes, the Consumer can be assured that all platform-specific buffer and cache updates have been performed, and that the LMR range has consistency with the Provider hardware. Any subsequent read by the Consumer can void this consistency. The Provider is not required to detect such access. The action performed on the cache before the RDMA Write depends on the cache type: o I/O noncoherent cache will be flushed. o CPU noncoherent cache will be invalidated. ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Interface Stability |Standard: uDAPL, 1.2 | +-----------------------------+-----------------------------+ |MT-Level |Unsafe | +-----------------------------+-----------------------------+ SEE ALSO
dat_lmr_sync_rdma_read(3DAT), libdat(3LIB), attributes(5) SunOS 5.11 16 Jul 2004 dat_lmr_sync_rdma_write(3DAT)
All times are GMT -4. The time now is 04:50 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy