The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
Google UNIX.COM


UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Problem with stack overflow karthikb23 HP-UX 0 03-26-2008 01:02 AM
what is stack winding and stack unwinding amitpansuria High Level Programming 2 08-07-2007 02:46 PM
memory stack aladdin UNIX for Dummies Questions & Answers 1 05-16-2007 06:17 AM
stack query aloksave High Level Programming 4 09-16-2005 10:10 AM
memory stack problem jkeagy High Level Programming 3 08-11-2005 09:39 AM

Closed Thread
 
Submit Tools LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 03-28-2002
mastaCow
Guest
 

Posts: n/a
Stumble this Post!
stack problem

Hi,
I'm a complete beginner at all this business so any help is appreciated.

I have a script (not written by me) which I need to modify. My problems is....

tail -1c $file

.... I understand this will return the final character of the $file variable. I need to make it return the first character of the $file variable. I've already tried first, top, front etc. but non seem to work.

And please don't ask what version of unix i'm running - all I do is boot up windows and use a program called Exceed.

Cheers for any help.
Forum Sponsor
  #2 (permalink)  
Old 03-28-2002
Neo's Avatar
Neo Neo is offline
Administrator
 

Join Date: Sep 2000
Location: Asia Pacific
Posts: 4,270
Stumble this Post!
Perhaps you might try the head command and not tail ...
  #3 (permalink)  
Old 03-28-2002
mastaCow
Guest
 

Posts: n/a
Stumble this Post!
I can only get head to return a set number of lines. i.e. head -n1 would return the first line. I need something to return the first character/byte etc. Is there an a -? I can use to make it output only the first character?

Thanks
  #4 (permalink)  
Old 04-02-2002
Jimbo
Guest
 

Posts: n/a
Stumble this Post!
Quote:
I understand this will return the final character of the $file variable.
Just to be clear, we are talking about returning the first or final character of a file, and does not matter if it is referenced by actual name or the filename is contained in a variable. Returning portions of what is currently held in a variable is very common, but I think not what we want here.

OK, so head -1 myfile gets you the first line. Now pipe that into a command that will cut the first column out. But if the first line is empty, this solution results in null:
Code:
char1=`head -1 myfile | cut -c1`
echo "first character is $char1"
  #5 (permalink)  
Old 04-02-2002
Kelam_Magnus's Avatar
Unix does a body good.
 

Join Date: Aug 2001
Location: DFW McKinney, TX,
Posts: 1,069
Stumble this Post!
Homework problem???

Obvious homework questions. I have reviewed your posts and all of them show classic homework type questions.

Please read the FAQs on the www.unix.com home page.
__________________
My brain is your brain
Google The UNIX and Linux Forums
Closed Thread

Thread Tools
Display Modes




All times are GMT -7. The time now is 05:30 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008 The CEP Blog All Rights Reserved -Ad Management by RedTyger Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0