Sponsored Content
Full Discussion: File Handling
Top Forums UNIX for Dummies Questions & Answers File Handling Post 302760945 by Yoda on Thursday 24th of January 2013 10:28:07 PM
Old 01-24-2013
Code:
split -d -l 1000 filename filename_out

head -1 filename > header
tail -1 filename > trailer

for file in filename_out*
do
   cat header ${file} trailer > tmp
   mv tmp ${file}
done

 

10 More Discussions You Might Find Interesting

1. Programming

File Handling in C

Hi all, I have a problem in handling files through C. here is the problem im having: i will query the database (for instance consider employees table ) for empno,ename,job,salary fields.The query returns me some 100 of rows. now i need to place them in a file in row wise pattern as they... (3 Replies)
Discussion started by: trinath
3 Replies

2. Programming

file handling

Hi all, I got a little issue here. Imagine that I have more than one process accessing one file. Is it possible to know which process(es) are accessing that file when I open the file?? Thanks for the help. Best regards, Ernesto (2 Replies)
Discussion started by: ninjanesto
2 Replies

3. UNIX for Advanced & Expert Users

File Handling

Hi, I have a log file which runs into 3 to 5 GB. We store this typically for 6 months. When a new month starts we move the previous month into a 9 month back up log (file.9m) and delete the last month of the 9 month back up. Iam using awk to find the data and cat to join the files like... (3 Replies)
Discussion started by: baanprog
3 Replies

4. UNIX for Advanced & Expert Users

please help me in file handling

sir i have to get first line from a file for example >cat file1 abc zxc asd adsf from that file1 i need only first line expected result >abc please help me ! (1 Reply)
Discussion started by: ponmuthu
1 Replies

5. UNIX for Advanced & Expert Users

File handling

my input for a script is another csv file but in that file say 7 lines are there ... how can i get line by line to that input for example : >cat link.csv www.yahoo.com,yahoo www.google.com,google www.unix.com,unix another file in that file i need to ping the above links ... (2 Replies)
Discussion started by: ponmuthu
2 Replies

6. Shell Programming and Scripting

UNIX File handling -Issue in reading a file

I have been doing automation of daily check activity for a server, i have been using sqls to retrive the data and while loop for reading the data from the file for several activities. BUT i got a show stopper the below one.. where the data is getting store in $temp_file, but not being read by while... (1 Reply)
Discussion started by: KuldeepSinghTCS
1 Replies

7. Programming

Perl help for file handling

$# some text $$ some text $@ some text $$. some text Mg1 some text Mg2 some text . . . Mg10 some text The above 10 lines are to be extracted except the lines starting from $#,$$.,... (4 Replies)
Discussion started by: baig.abdul
4 Replies

8. Shell Programming and Scripting

ksh file handling

Specifically on RHEL 5.7. When does the underlying ksh process open and close files? Every time they're accessed, or as little as possible? Say you have some script like: CreateFiles() { grep "<VALUE1>" ${infile} >> ${outfile} grep "<VALUE2>" ${infile} >> ${outfile} ...... (4 Replies)
Discussion started by: CarloM
4 Replies

9. UNIX for Dummies Questions & Answers

File handling

I have a file 1 298167 298168 1093209 1093210 1422663 I want to write a code where in I want to read contents of above file like first read is 1 second read is 298167 Substract second read from first and if this is greater than or less than 99,999. Similarly I want to traverse thru... (3 Replies)
Discussion started by: Guru148
3 Replies

10. Shell Programming and Scripting

File handling

Hi All, I need to extract the data from the text file. The data of the text file is shown below #L 0.000017 4.329939 0.000017 4.716267 r7.9 P 1 1;Net=IN32 The extracted data should be IN32. Could anyone help to script in c shell.? (4 Replies)
Discussion started by: gopishrine
4 Replies
cut(1)								   User Commands							    cut(1)

NAME
cut - cut out selected fields of each line of a file SYNOPSIS
cut -b list [-n] [file...] cut -c list [file...] cut -f list [-d delim] [-s] [file...] DESCRIPTION
Use the cut utility to cut out columns from a table or fields from each line of a file; in data base parlance, it implements the projection of a relation. The fields as specified by list can be fixed length, that is, character positions as on a punched card (-c option) or the length can vary from line to line and be marked with a field delimiter character like <TAB> (-f option). cut can be used as a filter. Either the -b, -c, or -f option must be specified. Use grep(1) to make horizontal ``cuts'' (by context) through a file, or paste(1) to put files together column-wise (that is, horizontally). To reorder columns in a table, use cut and paste. OPTIONS
The following options are supported: list A comma-separated or blank-character-separated list of integer field numbers (in increasing order), with optional - to indicate ranges (for instance, 1,4,7; 1-3,8; -5,10 (short for 1-5,10); or 3- (short for third through last field)). -b list The list following -b specifies byte positions (for instance, -b1-72 would pass the first 72 bytes of each line). When -b and -n are used together, list is adjusted so that no multi-byte character is split. -c list The list following -c specifies character positions (for instance, -c1-72 would pass the first 72 characters of each line). -d delim The character following -d is the field delimiter (-f option only). Default is tab. Space or other characters with special meaning to the shell must be quoted. delim can be a multi-byte character. -f list The list following -f is a list of fields assumed to be separated in the file by a delimiter character (see -d ); for instance, -f1,7 copies the first and seventh field only. Lines with no field delimiters will be passed through intact (use- ful for table subheadings), unless -s is specified. -n Do not split characters. When -b list and -n are used together, list is adjusted so that no multi-byte character is split. -s Suppresses lines with no delimiter characters in case of -f option. Unless specified, lines with no delimiters will be passed through untouched. OPERANDS
The following operands are supported: file A path name of an input file. If no file operands are specified, or if a file operand is -, the standard input will be used. USAGE
See largefile(5) for the description of the behavior of cut when encountering files greater than or equal to 2 Gbyte (2**31 bytes). EXAMPLES
Example 1: Mapping user IDs A mapping of user IDs to names follows: example% cut -d: -f1,5 /etc/passwd Example 2: Setting current login name To set name to current login name: example$ name=`who am i | cut -f1 -d' '` ENVIRONMENT VARIABLES
See environ(5) for descriptions of the following environment variables that affect the execution of cut: LANG, LC_ALL, LC_CTYPE, LC_MES- SAGES, and NLSPATH. EXIT STATUS
The following exit values are returned: 0 All input files were output successfully. >0 An error occurred. ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Availability |SUNWcsu | +-----------------------------+-----------------------------+ |CSI |Enabled | +-----------------------------+-----------------------------+ |Interface Stability |Standard | +-----------------------------+-----------------------------+ SEE ALSO
grep(1), paste(1), attributes(5), environ(5), largefile(5), standards(5) DIAGNOSTICS
cut: -n may only be used with -b cut: -d may only be used with -f cut: -s may only be used with -f cut: cannot open <file> Either file cannot be read or does not exist. If multiple files are present, processing continues. cut: no delimiter specified Missing delim on -d option. cut: invalid delimiter cut: no list specified Missing list on -b, -c, or -f option. cut: invalid range specifier cut: too many ranges specified cut: range must be increasing cut: invalid character in range cut: internal error processing input cut: invalid multibyte character cut: unable to allocate enough memory SunOS 5.10 29 Apr 1999 cut(1)
All times are GMT -4. The time now is 07:25 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy