Sponsored Content
Top Forums Programming Results Of A Variable Into An Array Using C Language Post 302929352 by Corona688 on Friday 19th of December 2014 04:54:45 PM
Old 12-19-2014
Speaking more generally, C does have a way to slurp an entire file into memory at once: mmap. It's actually better than reading it into memory, a 200MB file won't waste 200MB RAM just sitting there, only the parts you're using will actually be "read". To your program, it's a giant array of bytes corresponding to the entire file.

Since you actually want the file to be organized into lines, etc, this may not be too useful for you.
This User Gave Thanks to Corona688 For This Post:
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

store awk results in a variable

I try to get the month (of last save) and the filename into a variable, is this possible ? something like this : for month in `ls -la | awk '{print $6}'` do if ] then a=filename of the matching file cp $a /Sep fi thanks, Steffen (1 Reply)
Discussion started by: forever_49ers
1 Replies

2. UNIX for Dummies Questions & Answers

Setting the Results of a Command to a Variable

Hi, Hi, I run the command: hostname to get the host back from the server: db201 Now, I need to take that result and set it to a variable. Can anyone help me with this?? I need to be able to use the same script on multiple servers so I do not want to hardcode the hostname result into... (1 Reply)
Discussion started by: stky13
1 Replies

3. Shell Programming and Scripting

Results of command execution into array

Hi Can anybody tell me how can I dump the results of execution of a command into array form? For example, I want to execute: and put each part of the result in an array element: Thanks (2 Replies)
Discussion started by: alirezan
2 Replies

4. Shell Programming and Scripting

Compare Array results

Hi, In a kshell , i need to compare the results of two array . each Non-match value should copy to a new array. For example: ========== Array one contain the following values: A B C Array two contain the following values: C F A E After comparing this arrays , a new array should... (4 Replies)
Discussion started by: yoavbe
4 Replies

5. UNIX for Dummies Questions & Answers

how to - redirect query results to a variable

How can I send the results of a query to a unix variable. I basically want to run a query then do some logic on the results. Trying to redirect the result into a variable I define in the script. select count(*) as counter from table - nut to redirect the "count" returned from the query... (2 Replies)
Discussion started by: rstone
2 Replies

6. Shell Programming and Scripting

Adding results of a find to an array

I'm trying to add the paths of all the xml files in certain directories to an array. I want to use the array later in my code. Anyway, for some reason this isn't working. Any help would be appreciated. Path_Counter=0 for result in "find * -name '*.xml'"; do XmlPath="$result" echo... (2 Replies)
Discussion started by: Fly_Moe
2 Replies

7. Shell Programming and Scripting

Adding grep'd results in a variable

Here is one I am baffled with; I have not used unix for a while and now that I am back it has been fun remembering and I have enjoyed it, for the most past. this is in ksh. I need to search in a file for the line with X1 and cut columns 20-25, put them into a variable, added them (dollar... (3 Replies)
Discussion started by: CougarMutt
3 Replies

8. Shell Programming and Scripting

Storing the SQL results in array variables

Requirement 1) I need to execute 15 SQL queries in oracle through linux script. All these query results needs to be stored in array variables. Requirement 2) And these 15 queries needs to be executed in parallel. Requirement 3) Once all the queries executed then the shell script should... (3 Replies)
Discussion started by: Niranjancse
3 Replies

9. Shell Programming and Scripting

Append awk results into file or array

for a in {1..100} do awk '{ sum+=$a} END {print sum}' a=$a file1 > file2 done I know I will get only one number if following the code above, how can I get 100 sum numbers in file2? (2 Replies)
Discussion started by: wanliushao
2 Replies

10. Shell Programming and Scripting

I want to add a variable for the results from the formula of one variable and results of another var

Good morning all, This is the file name in question OD_Orders_2019-02-19.csv I am trying to create a bash script to read into files with yesterdays date on the file name while retaining the rest of the files name. I would like for $y to equal, the name of the file with a formula output with... (2 Replies)
Discussion started by: Ibrahim A
2 Replies
TMPFS(5)						     Linux Programmer's Manual							  TMPFS(5)

NAME
tmpfs - a virtual memory filesystem DESCRIPTION
The tmpfs facility allows the creation of filesystems whose contents reside in virtual memory. Since the files on such filesystems typi- cally reside in RAM, file access is extremely fast. The filesystem is automatically created when mounting a filesystem with the type tmpfs via a command such as the following: $ sudo mount -t tmpfs -o size=10M tmpfs /mnt/mytmpfs A tmpfs filesystem has the following properties: * The filesystem can employ swap space when physical memory pressure demands it. * The filesystem consumes only as much physical memory and swap space as is required to store the current contents of the filesystem. * During a remount operation (mount -o remount), the filesystem size can be changed (without losing the existing contents of the filesys- tem). If a tmpfs filesystem is unmounted, its contents are discarded (lost). Mount options The tmpfs filesystem supports the following mount options: size=bytes Specify an upper limit on the size of the filesystem. The size is given in bytes, and rounded up to entire pages. The size may have a k, m, or g suffix for Ki, Mi, Gi (binary kilo (kibi), binary mega (mebi) and binary giga (gibi)). The size may also have a % suffix to limit this instance to a percentage of physical RAM. The default, when neither size nor nr_blocks is specified, is size=50%. nr_blocks=blocks The same as size, but in blocks of PAGE_CACHE_SIZE. Blocks may be specified with k, m, or g suffixes like size, but not a % suffix. nr_inodes=inodes The maximum number of inodes for this instance. The default is half of the number of your physical RAM pages, or (on a machine with highmem) the number of lowmem RAM pages, whichever is smaller. Inodes may be specified with k, m, or g suffixes like size, but not a % suffix. mode=mode Set initial permissions of the root directory. gid=gid (since Linux 2.5.7) Set the initial group ID of the root directory. uid=uid (since Linux 2.5.7) Set the initial user ID of the root directory. huge=huge_option (since Linux 4.7.0) Set the huge table memory allocation policy for all files in this instance (if CONFIG_TRANSPARENT_HUGE_PAGECACHE is enabled). The huge_option value is one of the following: never Do not allocate huge pages. This is the default. always Attempt to allocate huge pages every time a new page is needed. within_size Only allocate huge page if it will be fully within i_size. Also respect fadvise(2)/madvise(2) hints advise Only allocate huge pages if requested with fadvise(2)/madvise(2). deny For use in emergencies, to force the huge option off from all mounts. force Force the huge option on for all mounts; useful for testing. mpol=mpol_option (since Linux 2.6.15) Set the NUMA memory allocation policy for all files in this instance (if CONFIG_NUMA is enabled). The mpol_option value is one of the following: default Use the process allocation policy (see set_mempolicy(2)). prefer:node Preferably allocate memory from the given node. bind:nodelist Allocate memory only from nodes in nodelist. interleave Allocate from each node in turn. interleave:nodelist Allocate from each node of in turn. local Preferably allocate memory from the local node. In the above, nodelist is a comma-separated list of decimal numbers and ranges that specify NUMA nodes. A range is a pair of hyphen-separated decimal numbers, the smallest and largest node numbers in the range. For example, mpol=bind:0-3,5,7,9-15. VERSIONS
The tmpfs facility was added in Linux 2.4, as a successor to the older ramfs facility, which did not provide limit checking or allow for the use of swap space. NOTES
In order for user-space tools and applications to create tmpfs filesystems, the kernel must be configured with the CONFIG_TMPFS option. The tmpfs filesystem supports extended attributes (see xattr(7)), but user extended attributes are not permitted. An internal shared memory filesystem is used for System V shared memory (shmget(2)) and shared anonymous mappings (mmap(2) with the MAP_SHARED and MAP_ANONYMOUS flags). This filesystem is available regardless of whether the kernel was configured with the CONFIG_TMPFS option. A tmpfs filesystem mounted at /dev/shm is used for the implementation of POSIX shared memory (shm_overview(7)) and POSIX semaphores (sem_overview(7)). The amount of memory consumed by all tmpfs filesystems is shown in the Shmem field of /proc/meminfo and in the shared field displayed by free(1). The tmpfs facility was formerly called shmfs. SEE ALSO
df(1), du(1), memfd_create(2), mmap(2), set_mempolicy(2), shm_open(3), mount(8) The kernel source files Documentation/filesystems/tmpfs.txt and Documentation/admin-guide/mm/transhuge.rst. Linux 2019-03-06 TMPFS(5)
All times are GMT -4. The time now is 10:53 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy