Sponsored Content
Top Forums UNIX for Beginners Questions & Answers Cut command: can't make it cut fields Post 302971682 by Don Cragun on Sunday 24th of April 2016 03:09:48 AM
Old 04-24-2016
There are at least three ways to do this, but none of them work perfectly (depending on the number of files present and the collective lengths of their names, whether or not any of the filenames contain space or tab characters, and whether or not any of the filenames contain newline characters).

Note also that the ls utility goes to a lot of work to line up output fields while producing minimal line lengths. Converting the ls -l output to use a single tab as a field separator for all fields is likely to produce wider line lengths on display devices, and, depending on the variability of user and group name lengths, unaligned group and filename output fields.

But, before we can go into details on these possibilities, we do need clarification, as RavinderSingh13 asked, about what a "tutoring course" is.
 

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

how to cut fields

I want to cut two coloums simulatiously and paste in some other file for ex: cut d ' ' -f3 -f4 xxx | paste yyy - > zzz; from the above i want to cut two fileds 3 and 4 and paste as last coloums of single file (zzz). how to solve this regards rajan (1 Reply)
Discussion started by: rajan_ka1
1 Replies

2. Shell Programming and Scripting

Cut Last 3 Fields

I have a text: dsj khfksjdh <time> EST 2006 ab cgnr jkkjt <time> EST 2006 gfhdgjghg <time> EST 2006 fkdjh kjhsekjrh kdjhfkh jhdfkhfdkjh kjdf <time> EST 2006 In the above file i need to extract time from every line... which is always the third from the last... Pls help! Cheers, Bouren (4 Replies)
Discussion started by: bourne
4 Replies

3. Shell Programming and Scripting

cut: get either one or two fields

Hello, I would like to extract one or two fields of a line. At the moment, I am extracting the first field of a line: command | cut -f 1 -d '.' > file The line can have two or three fields delimited with a dot. if three fields, I want to be able to get the first two ie if line =... (3 Replies)
Discussion started by: maxvirrozeito
3 Replies

4. Shell Programming and Scripting

awk sed cut? to rearrange random number of fields into 3 fields

I'm working on formatting some attendance data to meet a vendors requirements to upload to their system. With some help on the forums here, I have the data close. But they've since changed what they want. The vendor wants me to submit three fields to them. Field 1 is the studentid field,... (4 Replies)
Discussion started by: axo959
4 Replies

5. Shell Programming and Scripting

Cut Command error cut: Bad range

Hi Can anyone what I am doing wrong while using cut command. for f in *.log do logfilename=$f Log "Log file Name: $logfilename" logfile1=`basename $logfilename .log` flength=${#logfile1} Log "file length $flength" from_length=$(($flength - 15)) Log "from... (2 Replies)
Discussion started by: dgmm
2 Replies

6. Shell Programming and Scripting

How to make the cut command read a column after logical statements are meet?

Hi, I want to write a code that will cut everything that is under a couple of columns in a text file but so far I am not even close to achieve something like that. Basically, I want to cut all the information from the columns and transfer the column information to a spread sheet. I have... (1 Reply)
Discussion started by: pericopericone
1 Replies

7. UNIX for Dummies Questions & Answers

Cut pid from ps using cut command

hay i am trying to get JUST the PID from the ps command. my command line is: ps -ef | grep "mintty" | cut -d' ' -f2 but i get an empty line. i assume that the delimiter is not just one space character, but can't figure out what should i do in order to do that. i know i can use awk or cut... (8 Replies)
Discussion started by: ran ber
8 Replies

8. Shell Programming and Scripting

Need a separator string between fields in cut -c command

Hi All, I'm trying to view data using cut command for a fixed length file using the below command: cut -c 1-3,4-5 FALCON_PIS_00000000.dat I want to mention a separator say | (pipe) in between 1-3 and 4-5. Please let me know how to achieve this. Thanks in Advance, (3 Replies)
Discussion started by: HemaV
3 Replies

9. Shell Programming and Scripting

How To Count Fields For Cut?

I am new to cut and I want to use the field option with a space delimiter on an Apache log file. For example, if I wanted to find the 200 HTTP code using cut in this manner on the file below cat access_abc.log | cut -d' ' -f7 | grep "200" 157.55.39.183 - - "GET /content/696-news041305... (4 Replies)
Discussion started by: sharingsunshine
4 Replies
expand(1)						      General Commands Manual							 expand(1)

NAME
expand, unexpand - expand tabs to spaces, and vice versa SYNOPSIS
tablist] [file ...] tablist] [file ...] Obsolescent: tabstop] tabn] [file ...] DESCRIPTION
processes the named files or the standard input and writes to the standard output with tabs changed into spaces. Backspace characters are preserved in the output, and the column count is decreased by one column for tab calculations. For proper tab calculation, if a multi-col- umn character is to be "backspace'd", it should be followed by multiple backspace characters which equal to it's column width. If a tab character is found after the last tab position, it is replaced by a single space. is useful for preprocessing character files that contain tabs (before sorting, looking at specific columns, etc). recognizes the following command-line options and arguments: tablist specifies where to set the tab positions instead of the default tablist can take two forms. If it is a single num- ber, tabs are set tablist spaces apart. tablist can also be a blank- or comma-separated list of increasing positions where tabs are to be set. This option is obsolescent and is equivalent to using This option is obsolescent and is equivalent to using processes the named files or the standard input and writes to the standard output with spaces changed into tabs where possible. By default, only leading spaces and tabs are converted to maximal strings of tabs. The default tab position is every 8 characters. Backspace characters are preserved into the output, and the column count is decreased by one column for tab calculations. For proper tab calcula- tion, if a multi-column character is to be "backspace'd", it should be followed by multiple backspace characters which equal to it's column width. recognizes the following command-line options and arguments: Tabs are inserted whenever they would compress the resultant file by replacing two or more spaces before a tab position. tablist specifies the tab positions. tablist can take two forms. If it is a single number, tabs are set every tablist spa- ces apart. If tablist is a blank- or comma-separated list of increasing positions, tabs are set at those locations. The option implies the option. If the option is not specified, the default is equivalent to specifying except that is not implied for this case. EXTERNAL INFLUENCES
Environment Variables determines the interpretation of text as single and/or multi-byte characters. determines the language in which messages are displayed. If or is not specified in the environment or is set to the empty string, the value of is used as a default for each unspecified or empty variable. If is not specified or is set to the empty string, a default of "C" (see lang(5)) is used instead of If any internationalization variable contains an invalid setting, and behave as if all internationalization variables are set to "C". See environ(5). If is set to a non-empty string value, it overrides the values of all the other internationalization variables. International Code Set Support Single- and multi-byte character code sets are supported with the exception that do not recognize multi-byte alternative space characters. STANDARDS CONFORMANCE
expand(1)
All times are GMT -4. The time now is 04:48 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy