The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Advanced & Expert Users
.
google unix.com



UNIX for Advanced & Expert Users Expert-to-Expert. Learn advanced UNIX, UNIX commands, Linux, Operating Systems, System Administration, Programming, Shell, Shell Scripts, Solaris, Linux, HP-UX, AIX, OS X, BSD.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Real smart question Peterh UNIX for Advanced & Expert Users 2 07-25-2005 12:24 PM
Smart Crash Handling d11wtq UNIX for Dummies Questions & Answers 0 07-05-2005 08:35 AM
Smart Array on a RP4440 marvin51796 UNIX for Advanced & Expert Users 1 03-21-2005 05:04 PM
compaq smart array 532 farmacy SCO 2 02-18-2004 10:40 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 06-30-2005
zylwyz's Avatar
zylwyz zylwyz is offline
Registered User
  
 

Join Date: Jun 2005
Location: I'm living in Unix :)
Posts: 53
Question smart question

eg. : there is a file - 322 bytes,
how can I (or you) view just a half of file (161 bytes)?
  #2 (permalink)  
Old 06-30-2005
jerardfjay jerardfjay is offline
Registered User
  
 

Join Date: Feb 2005
Posts: 146
what if the size of the file is odd number
  #3 (permalink)  
Old 06-30-2005
jerardfjay jerardfjay is offline
Registered User
  
 

Join Date: Feb 2005
Posts: 146
assuming your input file is in_file. You could code something like this


Code:
#! /usr/bin/ksh

size=$(wc -c in_file | awk -F " " '{print $1}')
half_size=`expr $size / 2`
split -b $half_size in_file

The result of the final split command will be two or three files name xaa, xab and xac. you will get two files if the in_file is even number in size else three files with the last file xac being just 1 byte.
If you wanted the first half just read xaa, else read xab and xac if available for the latter.

jerardfjay

Last edited by jerardfjay; 06-30-2005 at 04:48 PM.. Reason: more explanation
  #4 (permalink)  
Old 06-30-2005
jim mcnamara jim mcnamara is online now Forum Staff  
...@...
  
 

Join Date: Feb 2004
Location: NM
Posts: 5,791
try:

Code:
 head -c -n 168 filename

This prints the first 168 bytes in the file.
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 04:02 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0