The UNIX and Linux Forums
Forum Home
Linux and Unix Man Pages
Search Forums
Search Community Posts
Today's Posts
Quick Links
Man Pages
RedHat Commands
OpenSolaris Commands
Linux Commands
SunOS Commands
FreeBSD Commands
All UNIX Man Pages
All Linux Man Pages
Full Man Repository
Login or Register to Ask a Question and Join Our Community
Search Forums
Show Threads .
Show Posts
Tag Search
Advanced Search
Quick Links
Contact Us
Forum Rules
Today's Posts
FAQ
Pictures & Albums
All Albums
Miscellaneous
What is My IP
Whois
Mark Forums Read
Shell Programming and Scripting
need help
Tags
need help
,
shell scripts
Login to Discuss or Reply to this Discussion in Our Community
Thread Tools
Search this Thread
Top Forums
Shell Programming and Scripting
need help
#
1
03-27-2008
girish.batra
Registered User
83,
0
Join Date: Jan 2008
Last Activity: 13 December 2011, 3:21 AM EST
Posts: 83
Thanks Given: 0
Thanked 0 Times in 0 Posts
need help
Dear all
There is a file called f1, having contents
1
2
3
4
.
.
.
0
Before 0, I don't know how many lines are there. I need to remove last line and save the output to file name called f2
girish.batra
View Public Profile for girish.batra
Find all posts by girish.batra
#
2
03-27-2008
era
Registered User
3,653,
12
Join Date: Mar 2008
Last Activity: 28 March 2011, 6:41 AM EDT
Location: /there/is/only/bin/sh
Posts: 3,653
Thanks Given: 0
Thanked 12 Times in 10 Posts
Code
:
sed '$d'
Applying it left as an exercise, as this is doubtlessly an assignment.
era
View Public Profile for era
Find all posts by era
#
3
03-27-2008
ghostdog74
Registered User
2,669,
20
Join Date: Sep 2006
Last Activity: 28 January 2015, 8:30 AM EST
Posts: 2,669
Thanks Given: 0
Thanked 20 Times in 20 Posts
for large files, use head
Code
:
# head -n -1 file
ghostdog74
View Public Profile for ghostdog74
Find all posts by ghostdog74
#
4
03-27-2008
era
Registered User
3,653,
12
Join Date: Mar 2008
Last Activity: 28 March 2011, 6:41 AM EDT
Location: /there/is/only/bin/sh
Posts: 3,653
Thanks Given: 0
Thanked 12 Times in 10 Posts
That's neat, but not very portable. Is that a GNUism or a POSIXism?
era
View Public Profile for era
Find all posts by era
Login or Register to Ask a Question
Previous Thread
|
Next Thread
Login or Register to Ask a Question
Member Badges and Information Modal
×