Sponsored Content
Full Discussion: ls in specific columns
Homework and Emergencies Homework & Coursework Questions ls in specific columns Post 302572090 by giampoul on Wednesday 9th of November 2011 07:32:04 AM
Old 11-09-2011
Quote:
Originally Posted by agama
This should work. It adjusts the directory column size based on the largest names seen in the list:

Code:
ls -pt | awk '
    /\/$/ {
        dcol[didx++] = $1;
        if( length( $1 ) > dmax )
            dmax = length( $1 );
        next;
    }
    {
        ccol[cidx++] = $1;
        next;
    }
    END {
        fmt = sprintf( "%%-%ds %%s\n", dmax );
        stop = didx > cidx ? didx : cidx;
        for( i = 0; i < stop; i++ )
            printf( fmt, dcol[i], ccol[i] );
    }
'

Very useful answer, thanks !
I try it but if a folder or file has space inside its name it doesn't give me the continue after the space..
for example if i have:
Code:
/dir 1  /file.exe
/dir 2  /dir3

I will get this answer:
Code:
/dir     /file.exe
/dir
/dir3

Smilie any ideas?
Also i have to use it inside c code.I should use system(); ??

Last edited by giampoul; 11-09-2011 at 09:29 AM..
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Replace specific columns

hi All, Thi sis very urgent. I have large files with pipe delimited. For example: 1.txt 1001024|120|9|-0.0|#| 1001025|120|9|#| 1001026|120|9|#| 1001032|120|2|-0.0|#| 1002026|110|9|#| 1002027|110|9|-0.0|#| 1002028|120|1|1.0|#| I need to replace the 4th filed if it is # by |-| my... (2 Replies)
Discussion started by: jisha
2 Replies

2. Shell Programming and Scripting

Mean of the specific columns

I have a input file that has some common values in 1st,2nd and 3rd columns. 4th and 5th are different. Now I would like to print the mean of the fourth column of similar values in 1st.2nd and 3rd columns along with all the values in 5th column. input NM_0 1.22 CR5 0.4 n_21663... (10 Replies)
Discussion started by: repinementer
10 Replies

3. Shell Programming and Scripting

Replace specific columns in one file with columns in another file

HELLO! This is my first post here! By the way, I think it is great that people do this. My question: I have two files, one is a .dilm and one is a .txt. It is my understanding that the .dilm file can be treated as a .txt file. I wrote another program where I was able to manipulate it as if it... (3 Replies)
Discussion started by: mehdib
3 Replies

4. UNIX for Dummies Questions & Answers

How to delete all columns that start with a specific value

I have this space delimited large text file with more than 1,000,000+ columns and about 100 rows. I want to delete all the columns that start with NA such that: File before modification aa bb cc NA100 dd aa b1 c2 NA101 de File after modification aa bb cc dd aa b1 c2 de How would I... (3 Replies)
Discussion started by: evelibertine
3 Replies

5. Shell Programming and Scripting

Deleting specific columns

Hi group, Can you please tell how to delete specific columns from a file. I know something like awk -F, '{ print $1" "$2" "15 }' input.txt > output.txt will delete all other columns. But this is in a way to copy some particular columns. But is there any other way to select just some... (11 Replies)
Discussion started by: smitra
11 Replies

6. Shell Programming and Scripting

Can't figure out how to find specific characters in specific columns

I am trying to find a specific set of characters in a long file. I only want to find the characters in column 265 for 4 bytes. Is there a search for that? I tried cut but couldn't get it to work. Ex. I want to find '9999' in column 265 for 4 bytes. If it is in there, I want it to print... (12 Replies)
Discussion started by: Drenhead
12 Replies

7. UNIX for Dummies Questions & Answers

Printing lines with specific strings at specific columns

Hi I have a file which is tab-delimited. Now, I'd like to print the lines which have "chr6" string in both first and second columns. Could anybody help? (3 Replies)
Discussion started by: a_bahreini
3 Replies

8. UNIX for Dummies Questions & Answers

Intersection by specific columns

Hi, I'd like to intersect two files by the 4th col of the first file and 6th col of the second file. This is the code I use: awk 'NR==FNR{A;next}$6 File1 File2 However, this is only outputting the second file lines. I'd like to have both lines in a single line separated by a tab. Thanks in... (25 Replies)
Discussion started by: a_bahreini
25 Replies

9. UNIX for Dummies Questions & Answers

Grep in specific columns

I am trying to search a list of strings from a file and display the string as well as the column in the search file it was found. I dont care about the row. what is wrong with my script? while read line; do awk -v var="$line" '{for(i=1;i<NF;i++) if ($NF==$var) break; print $var FS $NF' }'... (3 Replies)
Discussion started by: senhia83
3 Replies

10. Shell Programming and Scripting

Converting data from specific columns

i have a file (csv or txt or anything which has 4 columns (id,name,number,location) and it contains data. i want to convert the data of specific columns like name to ooooo and number to 88888 matching the field length of that columns. for example if name column has anthony which is 7, it should... (2 Replies)
Discussion started by: prajaktaraut
2 Replies
PAPI_enum_cmp_event(3)						       PAPI						    PAPI_enum_cmp_event(3)

NAME
PAPI_enum_cmp_event - Enumerate PAPI preset or native events for a given component. SYNOPSIS
Detailed Description @par C Interface: int PAPI_enum_cmp_event( int *EventCode, int modifer, int cidx ); Given an event code, PAPI_enum_event replaces the event code with the next available event. The modifier argument affects which events are returned. For all platforms and event types, a value of PAPI_ENUM_ALL (zero) directs the function to return all possible events. @n For native events, the effect of the modifier argument may be different on each platform. See the discussion below for platform-specific definitions. @param *EventCode A defined preset or native event such as PAPI_TOT_INS. @param modifier Modifies the search logic. See below for full list. For native events, each platform behaves differently. See platform-specific documentation for details. @param cidx Specifies the component to search in @retval PAPI_ENOEVNT The next requested PAPI preset or native event is not available on the underlying hardware. @par Examples: * // Scan for all supported native events on the first component * printf( "Name Code Description0 ); * do { * retval = PAPI_get_event_info( i, &info ); * if ( retval == PAPI_OK ) { * printf( "%-30s 0x%-10x1s0, info.symbol, info.event_code, info.long_descr ); * } * } while ( PAPI_enum_cmp_event( &i, PAPI_ENUM_ALL, 0 ) == PAPI_OK ); * Generic Modifiers The following values are implemented for preset events o PAPI_ENUM_EVENTS -- Enumerate all (default) o PAPI_ENUM_FIRST -- Enumerate first event (preset or native) preset/native chosen based on type of EventCode Native Modifiers The following values are implemented for native events o PAPI_NTV_ENUM_UMASKS -- Given an event, iterate through possible umasks one at a time o PAPI_NTV_ENUM_UMASK_COMBOS -- Given an event, iterate through all possible combinations of umasks. This is not implemented on libpfm4. Preset Modifiers The following values are implemented for preset events o PAPI_PRESET_ENUM_AVAIL -- enumerate only available presets o PAPI_PRESET_ENUM_MSC -- Miscellaneous preset events o PAPI_PRESET_ENUM_INS -- Instruction related preset events o PAPI_PRESET_ENUM_IDL -- Stalled or Idle preset events o PAPI_PRESET_ENUM_BR -- Branch related preset events o PAPI_PRESET_ENUM_CND -- Conditional preset events o PAPI_PRESET_ENUM_MEM -- Memory related preset events o PAPI_PRESET_ENUM_CACH -- Cache related preset events o PAPI_PRESET_ENUM_L1 -- L1 cache related preset events o PAPI_PRESET_ENUM_L2 -- L2 cache related preset events o PAPI_PRESET_ENUM_L3 -- L3 cache related preset events o PAPI_PRESET_ENUM_TLB -- Translation Lookaside Buffer events o PAPI_PRESET_ENUM_FP -- Floating Point related preset events ITANIUM Modifiers The following values are implemented for modifier on Itanium: o PAPI_NTV_ENUM_IARR - Enumerate IAR (instruction address ranging) events o PAPI_NTV_ENUM_DARR - Enumerate DAR (data address ranging) events o PAPI_NTV_ENUM_OPCM - Enumerate OPC (opcode matching) events o PAPI_NTV_ENUM_IEAR - Enumerate IEAR (instr event address register) events o PAPI_NTV_ENUM_DEAR - Enumerate DEAR (data event address register) events POWER Modifiers The following values are implemented for POWER o PAPI_NTV_ENUM_GROUPS - Enumerate groups to which an event belongs See Also: PAPI PAPIF PAPI_enum_event PAPI_get_event_info PAPI_event_name_to_code PAPI_preset PAPI_native Author Generated automatically by Doxygen for PAPI from the source code. Version 5.2.0.0 Tue Jun 17 2014 PAPI_enum_cmp_event(3)
All times are GMT -4. The time now is 12:47 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy