Sponsored Content
Homework and Emergencies Homework & Coursework Questions Need help with a really basic assignment, probably gonna take you 5 mins to do.but it worse 7% to me Post 302624661 by Corona688 on Monday 16th of April 2012 01:48:24 PM
Old 04-16-2012
From man head:

Code:
       -n, --lines=[-]K
              print  the first K lines instead of the first 10; with the lead-
              ing `-', print all but the last K lines of each file

So -n expects the number of lines. If you're not giving it a number of lines, don't bother telling head -n.

You're improperly nesting your if's. If you want to do if/else, use elif. Or you could break it into two completely separate if-statements. And you still have the useless ;'s there.

And the 'return' still doesn't do anything like what you think it does. It doesn't jump to the top of the script. To loop, you need a loop.

Code:
if [ "$e" = 'y' ] || [ "$e" = 'Y' ]
then exit
elif [ "$e" =  'n'] || [ "$e" = 'N' ]
return
fi # only one fi

The first argument is $1. So ls -l $1. There's another argument you can give ls to reverse its order, which you can find via man ls.

You can tell how many arguments there are with the $# special variable. Something like if [ "$#" -eq 2 ] to do one thing when you have two arguments, and another when you don't.

You can redirect into a file with >. command > filename
This User Gave Thanks to Corona688 For This Post:
 

6 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

files created within last 10 mins

Any simple 1 liners to check a directory to see if a file was created within the last 10 mins? (5 Replies)
Discussion started by: frustrated1
5 Replies

2. Shell Programming and Scripting

tail for 15 mins

Hi, I want to write a script which will tail a particular file for 15 mins and then sleep for 10 mins and again tail for 15 mins. This cycle will go on for a limited period of time. How can i ensure that tail command will run for 15 mins before calling sleep command Thanks (6 Replies)
Discussion started by: @bhi
6 Replies

3. Red Hat

When is RHEL 7 Gonna Release?

When is RHEL 7 Gonna Release and When will the Exam Will be Conducted Any one have idea ? :mad: (2 Replies)
Discussion started by: babinlonston
2 Replies

4. Shell Programming and Scripting

How to check if there is a file in the last 10 mins?

I have a script that runs every hour from the crontab (see the settings of the crontab below) (15 mins past the hour) 15 * * * * /home/usr/usr1/ProvAll This script saves two files in the following format now=`/bin/date '+%Y%m%d.%H%M%S'` file1.$now (for example) file1.20140722.031502... (12 Replies)
Discussion started by: knijjar
12 Replies

5. Shell Programming and Scripting

Need logs 5 mins old

I need 5 mins old logs to be dumped into a a new file. The date formats in the two log files are Can you suggect for both formats ? bash-3.2$ uname -a SunOS myserver 5.10 Generic_150400-26 sun4v sparc sun4v ---------- Post updated 05-04-16 at 12:24 AM ---------- Previous update was... (2 Replies)
Discussion started by: mohtashims
2 Replies

6. UNIX for Beginners Questions & Answers

Grep last 5 mins from logs

Hi, system date format Thu Jun 13 12:55:18 EDT 2019 My log date format 09.148.192.60 - - "GET /akamai/sureroute-test-object.html HTTP/1.1" 404 231 can someone please help me, how to get last 5mins of logs please ? I need the command Please wrap your samples/codes in CODE TAGS,... (3 Replies)
Discussion started by: scazed
3 Replies
HEAD(1) 								FSF								   HEAD(1)

NAME
head - output the first part of files SYNOPSIS
head [OPTION]... [FILE]... DESCRIPTION
Print first 10 lines of each FILE to standard output. With more than one FILE, precede each with a header giving the file name. With no FILE, or when FILE is -, read standard input. Mandatory arguments to long options are mandatory for short options too. -c, --bytes=SIZE print first SIZE bytes -n, --lines=NUMBER print first NUMBER lines instead of first 10 -q, --quiet, --silent never print headers giving file names -v, --verbose always print headers giving file names --help display this help and exit --version output version information and exit SIZE may have a multiplier suffix: b for 512, k for 1K, m for 1 Meg. AUTHOR
Written by David MacKenzie. REPORTING BUGS
Report bugs to <bug-coreutils@gnu.org>. COPYRIGHT
Copyright (C) 2002 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICU- LAR PURPOSE. SEE ALSO
The full documentation for head is maintained as a Texinfo manual. If the info and head programs are properly installed at your site, the command info head should give you access to the complete manual. head (coreutils) 4.5.3 February 2003 HEAD(1)
All times are GMT -4. The time now is 06:40 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy