Simple unit script

Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Simple unit script
# 1  
Old 03-03-2014
Error Simple unit script

Hello guys this is my first post in this forum. Since now ive been passive an ive only been looking for existing information. Now I could use specific help on a UNIX script i want to make that would:

1. Take 1-3 arguments.
2. Display the contents of its arguments, formatted as follows:
Separator line
Separator Line
File content
Separator line
3. Display an error message, in case the arguments are less than 1 or more than 3.

How can i do that? i'm so confused.SmilieSmilieSmilie
# 2  
Old 03-03-2014

Could you please be more clear on your requirement. Please share input and expected output with use for same. Also please make sure you are using code tags as per forum rules for code and commands please.

R. Singh
# 3  
Old 03-03-2014
If you're writing your script in Bash shell, you can handle the arguments like this:


# check command-line for correct usage
if [ $# -eq 0 ] || [ $# -gt 3 ]
    echo "Usage: ${0##*/} <arg1> <arg2> <arg3>"
    exit 1

Each argument will be stored in it's own variable: $1, $2, $3.
# 4  
Old 03-03-2014
After checking the number of parameters. One way is with a here document:
for file in "$@"
cat << EOF
$(cat "$file")


for file in "$@"
  printf "%s\n" "------------------------------------------"
  printf "%s\n" "$file"
  printf "%s\n" "------------------------------------------"
  cat "$file"
  printf "%s\n" "------------------------------------------"

@in2nix4life : that code will work with any POSIX shell, not just bash...
# 5  
Old 03-03-2014
in unix script code with commands like read and cp and chmod
# 6  
Old 03-03-2014
It is all shell script. Is this homework?
# 7  
Old 03-03-2014
yes it is and i've missed some classes and I dont know that basic stuff
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Count special symbols between each unit

Can anybody help me figure this out? Thank you in advance. I have a input file. It shows like this: Query= random content random content > random content random content > random content > random content Query= random content random content random content > random content > random... (1 Reply)
Discussion started by: yuejian
1 Replies

2. Shell Programming and Scripting

Help making simple perl or bash script to create a simple matrix

Hello all! This is my first post and I'm very new to programming. I would like help creating a simple perl or bash script that I will be using in my work as a junior bioinformatician. Essentially, I would like to take a tab-delimted or .csv text with 3 columns and write them to a "3D" matrix: ... (16 Replies)
Discussion started by: torchij
16 Replies

3. HP-UX

Load average unit

Hi, On load average graph, unit is 100m, 200m, 300...800m. I don't understand what it means. Thx for helping (3 Replies)
Discussion started by: Michenux
3 Replies

4. Shell Programming and Scripting

Set of 2 records as one unit

Hi Experts, back at this forum again. Have a tab separated file like this --- ACCNN AMT(E/$) TYPE ID 11233 23.20($) AUTH 339 11233 19.00($) FINAL 339 11234 349.84($) AUTH 42332 11234 ... (12 Replies)
Discussion started by: PG3
12 Replies

5. UNIX for Advanced & Expert Users

Help with connecting 3 or 4 computers to one stereo unit

Nowadays I run Mandriva, Ubuntu and Fedora Core. All of the operating systems works fine on my computers. GRUB gives me the opportunity to select an operating system. I have Windows too. I don't run Windows. I like UNIX. Today I work with 3 computers with a single monitor. This is possible... (4 Replies)
Discussion started by: Angelo
4 Replies

6. Shell Programming and Scripting

Migration unit testing process

Hi, We are doing migration from DB2 to Teradata. There are couple of things involving in the project. Please see below following order Autosys-Jil script Profile script Category1 Teradata script Data stage job script Tera data script Export files script.. Like that we have 10000... (1 Reply)
Discussion started by: onesuri
1 Replies

7. Shell Programming and Scripting

Handling Unit Seperator Delimeter

Hi, We have a file with a unit seperator as the delimeter. Here are the Sample lines from the file: ASIA/PACIFICHong KongFX2007071080900 ASIA/PACIFICHong KongFX2007071080900/ 800129HK This delimeter has the ascii value of \037. I have to... (4 Replies)
Discussion started by: sviswana
4 Replies

8. Shell Programming and Scripting

Getting MAC from GPS unit

Never mind i got the answer thanks., (0 Replies)
Discussion started by: deaconf19
0 Replies

9. Filesystems, Disks and Memory

AIX and DS4300 Storage Unit

Hello, We're setting up a solution for a group of customers with 2 p520 servers and 1 DS4300 unit with 9 disks (at this stage). The meaning is to create two arrays on the DS4300. Both servers will be connected to the DS4300 unit and to both controllers (e.g. Controller 1 connected to server 1... (0 Replies)
Discussion started by: EricBE
0 Replies
Login or Register to Ask a Question