Sponsored Content
Full Discussion: Cut a File
Top Forums UNIX for Dummies Questions & Answers Cut a File Post 302863063 by Don Cragun on Saturday 12th of October 2013 03:55:19 AM
Old 10-12-2013
Look at your system's man page for the ftruncate() function.

If you need more help than this, you're going to have to convince me that this is not a misfiled homework assignment.
 

8 More Discussions You Might Find Interesting

1. 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

2. Shell Programming and Scripting

Creating file from an existing file using CUT, is it the best option?

Dear All, I have a requirement in which i have to load a file placed in FTP location onto my database. The process i'll follow is as below: 1) Get the files using FTP. 2) Create the desired load files as i have to load only 19 fields out of the 104 available in the file. The fields i require... (7 Replies)
Discussion started by: abhishekakaomi
7 Replies

3. Shell Programming and Scripting

cut lines from log file and save it another file

Dears, i want cut the lines from a log file. Example of the log file as follows.. May 27, 2011 5:54:51 PM com.huawei.ivas.utilities.sm.client.SMDeliverContrUtil isDeliverSM FINE: May 27, 2011 5:54:51 PM com.huawei.ivas.utilities.sm.client.SMUtil addSysUpMsgLog INFO: . The message content... (1 Reply)
Discussion started by: tonypalokkaran
1 Replies

4. Shell Programming and Scripting

cut the variable from the line and use it to find the file and read the content of that file

Hi, I am working on one script..I am having files in the below format file 1 (each line is separated with : delimeter) SPLASH:SPLASH:SVN CIB/MCH:MCH:SVN Now I want from file 1 that most left part of the first line will store in... (6 Replies)
Discussion started by: rohit22hamirpur
6 Replies

5. Shell Programming and Scripting

Help required the cut the whole contents from one file and paste it into new file

Hi, First of all sincere apologies if I have posted in a wrong section ! Please correct me if I am wrong ! I am very new to UNIX scripting. Currently my problem is that I have a code file at the location /home/usr/workarea/GeneratedLogs.log :- Code :- (Feb 7, 571 7:07:29 AM),... (4 Replies)
Discussion started by: acidburn_007
4 Replies

6. Shell Programming and Scripting

How to cut a pipe delimited file and paste it with another file to form a comma separated outputfile

Hello ppl I have a requirement to split (cut in unix) a file (A.txt) which is a pipe delimited file into A1.txt and A2.txt Now I have to join (paste in unix) this A2.txt with external file A3.txt to form output file A4.txt which should be CSV (comma separated file) so that third party can... (25 Replies)
Discussion started by: etldev
25 Replies

7. UNIX for Beginners Questions & Answers

Cut command: can't make it cut fields

I'm a complete beginner in UNIX (and not a computer science student either), just undergoing a tutoring course. Trying to replicate the instructions on my own I directed output of the ls listing command (lists all files of my home directory ) to My_dir.tsv file (see the screenshot) to make use of... (9 Replies)
Discussion started by: scrutinizerix
9 Replies

8. Shell Programming and Scripting

Using :<<cut / cut to comment out block of bash script

I am using : << cut / cut to comment out block of code. Works fine on few lines of script, then it gives me this cryptic error when I try to comment out about 80 lines. The "warning " is at last line of script. done < results 169 echo "END read all positioning parameters" 170... (8 Replies)
Discussion started by: annacreek
8 Replies
truncate(2)							System Calls Manual						       truncate(2)

NAME
truncate, ftruncate - Changes file length SYNOPSIS
#include <unistd.h> int truncate( const char *path, off_t length); int ftruncate( int filedes, off_t length); STANDARDS
Interfaces documented on this reference page conform to industry standards as follows: ftruncate(), truncate(): XSH4.2 Refer to the standards(5) reference page for more information about industry standards and associated tags. PARAMETERS
Specifies the name of a file that is opened, truncated, and then closed. The path parameter must point to a pathname which names a regular file for which the calling process has write permission. If the path parameter refers to a symbolic link, the length of the file pointed to by the symbolic link is truncated. Specifies the descriptor of a file that must be open for writing. Specifies the new length of the file in bytes. DESCRIPTION
The truncate() and ftruncate() functions change the length of a file to the size in bytes specified by the length parameter. If the new length is less than the previous length, the truncate() and ftruncate() functions remove all data beyond length bytes from the specified file. All file data between the new end-of-file and the previous end-of-file is discarded. If the new length is greater than the previous length, one byte of zero (0x00) is written at the offset of the new length. The space in between the previous end-of-file and the new end- of-file is left as a hole; that is, no blocks are allocated to the space in between the previous last block and the new last block. Full blocks are returned to the file system so that they can be used again, and the file size is changed to the value of the length parame- ter. The truncate() and ftruncate() functions have no effect on FIFO special files or directories. These functions do not modify the seek pointer of the file. Upon successful completion, the truncate() and ftruncate() functions mark the st_ctime and st_mtime fields of the file for update. If the file is a regular file, the ftruncate() and truncate() functions clear the S_ISUID and S_ISGID attributes of the file. If the file has enforced file locking enabled and there are file locks on the file, the truncate() or ftruncate() function fails. RETURN VALUES
Upon successful completion, a value of 0 (zero) is returned. If the truncate() or ftruncate() function fails, it returns a value of -1, and errno is set to indicate the error. ERRORS
The ftruncate() and truncate() functions set errno to the specified values for the following conditions: [Tru64 UNIX] The write operation failed due to an enforced write lock on the file. [Tru64 UNIX] The file has enforced mode file locking enabled and there are file locks on the file. The length parameter was greater than the maximum file size. A signal was caught during execution. The length parameter was less than 0 (zero). [Tru64 UNIX] The file is not a regular file. An I/O error occurred while reading from or writing to a file system. [Tru64 UNIX] The process' root or current directory is located in a virtual file system that has been unmounted. In addition, the ftruncate() function sets errno to the specified values for the following conditions: [Tru64 UNIX] Write access permis- sion to the file was denied. The filedes parameter is not a valid file descriptor open for writing. The fildes parameter references a file that was opened without write permission. [Tru64 UNIX] The file resides on a read-only file system. In addition, the truncate() function fails if errors occur that apply to any service requiring pathname resolution, or if one of the fol- lowing are true: A component of the path prefix denies search permission, or write permission is denied on the file. The named file is a directory. Too many symbolic links were encountered in resolving path. The size of the pathname exceeds PATH_MAX or a pathname component is longer than NAME_MAX. A component of the specified pathname does not exist, or the path parameter points to an empty string. A compo- nent of the path prefix is not a directory. The file resides on a read-only file system. RELATED INFORMATION
Functions: chmod(2), fcntl(2), open(2) Standards: standards(5) delim off truncate(2)
All times are GMT -4. The time now is 03:44 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy