Sponsored Content
Full Discussion: adding whitespace
Top Forums UNIX for Dummies Questions & Answers adding whitespace Post 302569160 by agama on Saturday 29th of October 2011 07:32:30 PM
Old 10-29-2011
Assuming that having all of your columns output in the same size field works, this is a quick and dirty hack:

Code:
awk '
    $2 > 30 && $5 == $3 {
        for( i = 1; i <= NF; i++ )
            printf( "%5s ", $(i) );      # change to the 5 to be the size of each col in characters
        printf( "\n" );
    }
'

Your example input would be printed like this with the %5s used above:

Code:
 file   455   664 
   go     -    54


This also assumes you want all columns to be printed.
This User Gave Thanks to agama For This Post:
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

trim whitespace?

I'm trying to find a command that will trim the white space off a string. e.g. $str = " stuf " $str = trim ( $str ) echo $str // ouput would just be stuf Thanks, Mark (4 Replies)
Discussion started by: msteudel
4 Replies

2. Shell Programming and Scripting

Delete whitespace

Hi, I have been trying to remove whitespace from a file using sed. Here is an example of what im trying to do: www1 = www1 www2 = www2 www3 = www3 and all the way to 300 and i want it to look like: www1=www1 www2-www2 www3=www3 again upto 300 Any help... (12 Replies)
Discussion started by: truck7758
12 Replies

3. Shell Programming and Scripting

Of bash and whitespace...

Hmmm... Bash doesn't parse whitespace with a read. lev@sys09:~$ read line; echo "$line" test test You can imagine what this does if you're using a shell script to read a list of unknown file names containing unknown spaces. lev@sys09:~$ read word1 word2; echo "$word1,$word2" 123 456... (2 Replies)
Discussion started by: lev_lafayette
2 Replies

4. Shell Programming and Scripting

split whitespace help

I have a file that I am spliting and parsing, if data starts with an N/n toos it (which works) but I want it to also see if the data is blank and toss it. What I have does not toss the blank space for dduck???? here is the data file and code I have..... efudd 7546 bbunny N0542 tdevil... (3 Replies)
Discussion started by: theninja
3 Replies

5. Shell Programming and Scripting

Whitespace Issues

Hello forums! I've been tinkering with a shell script to partition and restore content to a drive based on a type of file in a given directory. My goal is for my script to assemble several restore images, partition the drive based on the images and to then restore those images to the partitions... (1 Reply)
Discussion started by: rkasowan
1 Replies

6. UNIX for Dummies Questions & Answers

remove whitespace

I combined 2 files using the paste command. It gave me something like this: 123445 ,AABBNN 22344 ,BBVVMM I want to remove the whitespace between the end of string 1 and the comma (there is more blank space than my post is showing). Would I... (2 Replies)
Discussion started by: nickg
2 Replies

7. UNIX for Advanced & Expert Users

whitespace problem

I have a single string as below: Rat run after Cat i.e. there is a single whitespace after Cat. This causes my file to fail. Is there a way I can remove any whitespace at the end of any string. I tried sed 's/ *//g', but it removes all white space and the above string becomes... (10 Replies)
Discussion started by: RubinPat
10 Replies

8. Shell Programming and Scripting

How to match (whitespace digits whitespace) sequence?

Hi Following is an example line. echo "192.22.22.22 \"33dffwef\" 200 300 dsdsd" | sed "s:\(\ *\ \):\1:" I want it's output to be 200 However this is not the case. Can you tell me how to do it? I don't want to use AWK for this. Secondly, how can i fetch just 300? Should I use "\2"... (3 Replies)
Discussion started by: shahanali
3 Replies

9. Shell Programming and Scripting

Getting rid of whitespace

Hello I am working aon script, that tells me how many users or on the system when i run it. The script is #!/bin/bash w | cut -f 1 -d ' ' |sort -u | wc -l When ran it shows 16 users including myself and a line of white space. I was wondering what I need to add to remove my user... (2 Replies)
Discussion started by: mosdojaf
2 Replies

10. Shell Programming and Scripting

Separate by more than whitespace.

This is my file .........hostname.............this is hostname .........alias...................alias name Remark use dot(.) instead of whitespace B'cuz this forum not allow to use more whitespace. --------------------------------------- I sperate by whitespace not work. awk 'BEGIN {FS=" "}... (4 Replies)
Discussion started by: cyberking
4 Replies
BUF(9)							   BSD Kernel Developer's Manual						    BUF(9)

NAME
buf -- kernel buffer I/O scheme used in FreeBSD VM system DESCRIPTION
The kernel implements a KVM abstraction of the buffer cache which allows it to map potentially disparate vm_page's into contiguous KVM for use by (mainly file system) devices and device I/O. This abstraction supports block sizes from DEV_BSIZE (usually 512) to upwards of several pages or more. It also supports a relatively primitive byte-granular valid range and dirty range currently hardcoded for use by NFS. The code implementing the VM Buffer abstraction is mostly concentrated in /usr/src/sys/kern/vfs_bio.c. One of the most important things to remember when dealing with buffer pointers (struct buf) is that the underlying pages are mapped directly from the buffer cache. No data copying occurs in the scheme proper, though some file systems such as UFS do have to copy a little when deal- ing with file fragments. The second most important thing to remember is that due to the underlying page mapping, the b_data base pointer in a buf is always *page* aligned, not *block* aligned. When you have a VM buffer representing some b_offset and b_size, the actual start of the buffer is (b_data + (b_offset & PAGE_MASK)) and not just b_data. Finally, the VM system's core buffer cache supports valid and dirty bits (m->valid, m->dirty) for pages in DEV_BSIZE chunks. Thus a platform with a hardware page size of 4096 bytes has 8 valid and 8 dirty bits. These bits are generally set and cleared in groups based on the device block size of the device backing the page. Complete page's worth are often referred to using the VM_PAGE_BITS_ALL bitmask (i.e., 0xFF if the hardware page size is 4096). VM buffers also keep track of a byte-granular dirty range and valid range. This feature is normally only used by the NFS subsystem. I am not sure why it is used at all, actually, since we have DEV_BSIZE valid/dirty granularity within the VM buffer. If a buffer dirty operation creates a 'hole', the dirty range will extend to cover the hole. If a buffer validation operation creates a 'hole' the byte-granular valid range is left alone and will not take into account the new extension. Thus the whole byte-granular abstraction is considered a bad hack and it would be nice if we could get rid of it completely. A VM buffer is capable of mapping the underlying VM cache pages into KVM in order to allow the kernel to directly manipulate the data associ- ated with the (vnode,b_offset,b_size). The kernel typically unmaps VM buffers the moment they are no longer needed but often keeps the 'struct buf' structure instantiated and even bp->b_pages array instantiated despite having unmapped them from KVM. If a page making up a VM buffer is about to undergo I/O, the system typically unmaps it from KVM and replaces the page in the b_pages[] array with a place-marker called bogus_page. The place-marker forces any kernel subsystems referencing the associated struct buf to re-lookup the associated page. I believe the place-marker hack is used to allow sophisticated devices such as file system devices to remap underlying pages in order to deal with, for example, re-mapping a file fragment into a file block. VM buffers are used to track I/O operations within the kernel. Unfortunately, the I/O implementation is also somewhat of a hack because the kernel wants to clear the dirty bit on the underlying pages the moment it queues the I/O to the VFS device, not when the physical I/O is actually initiated. This can create confusion within file system devices that use delayed-writes because you wind up with pages marked clean that are actually still dirty. If not treated carefully, these pages could be thrown away! Indeed, a number of serious bugs related to this hack were not fixed until the 2.2.8/3.0 release. The kernel uses an instantiated VM buffer (i.e., struct buf) to place-mark pages in this special state. The buffer is typically flagged B_DELWRI. When a device no longer needs a buffer it typically flags it as B_RELBUF. Due to the underlying pages being marked clean, the B_DELWRI|B_RELBUF combination must be interpreted to mean that the buffer is still actually dirty and must be written to its backing store before it can actually be released. In the case where B_DELWRI is not set, the underlying dirty pages are still properly marked as dirty and the buffer can be completely freed without losing that clean/dirty state information. (XXX do we have to check other flags in regards to this situation ???) The kernel reserves a portion of its KVM space to hold VM Buffer's data maps. Even though this is virtual space (since the buffers are mapped from the buffer cache), we cannot make it arbitrarily large because instantiated VM Buffers (struct buf's) prevent their underlying pages in the buffer cache from being freed. This can complicate the life of the paging system. HISTORY
The buf manual page was originally written by Matthew Dillon and first appeared in FreeBSD 3.1, December 1998. BSD
December 22, 1998 BSD
All times are GMT -4. The time now is 10:02 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy