469,603 Members | 2,144 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,603 developers. It's quick & easy.

Complete NOOB need help

1
I am a complete noob to linux and shell scripting please help

this is what I am trying to do
1. Create a script that takes 1 argument being a file, read the inputted file, and look for occurrences of the current user who is executing the script. On finding an occurrence of the username take that line and append it to a file and display a line number and a bracket against the saved line

efforts sofar

Expand|Select|Wrap|Line Numbers
  1. #!/bin/bash
  2. echo "filename"
  3. read myvar
  4. grep $USER $myvar > results.txt
  5. nl results.txt
  6.  

2. Write a script that takes two arguments. The first being a line of text, the second being a file. The script should take the first argument and insert it into the middle (the middle line) of the file named in second argument.


thanks in advancefor any help
Jun 5 '07 #1
3 2097
I am a complete noob to linux and shell scripting please help

this is what I am trying to do
1. Create a script that takes 1 argument being a file, read the inputted file, and look for occurrences of the current user who is executing the script. On finding an occurrence of the username take that line and append it to a file and display a line number and a bracket against the saved line

efforts sofar

Expand|Select|Wrap|Line Numbers
  1. #!/bin/bash
  2. echo "filename"
  3. read myvar
  4. grep $USER $myvar > results.txt
  5. nl results.txt
  6.  

2. Write a script that takes two arguments. The first being a line of text, the second being a file. The script should take the first argument and insert it into the middle (the middle line) of the file named in second argument.


thanks in advancefor any help
A scratch code might be
Expand|Select|Wrap|Line Numbers
  1. #!/bin/sh
  2.  
  3. cat $1 | grep $USER >> files.txt
  4. cat files.txt | grep $USER
  5.  
  6.  
Jul 7 '07 #2
ghostdog74
511 Expert 256MB
A scratch code might be
Expand|Select|Wrap|Line Numbers
  1. #!/bin/sh
  2.  
  3. cat $1 | grep $USER >> files.txt
  4. cat files.txt | grep $USER
  5.  
  6.  
don't teach a noob the "wrong" things. both the above cats are useless. grep takes in a file as input.
Expand|Select|Wrap|Line Numbers
  1. grep $USER $1 >> files.txt
  2. grep $USER files.txt
  3.  
Jul 8 '07 #3
ghostdog74
511 Expert 256MB
I am a complete noob to linux and shell scripting please help

this is what I am trying to do
1. Create a script that takes 1 argument being a file, read the inputted file, and look for occurrences of the current user who is executing the script. On finding an occurrence of the username take that line and append it to a file and display a line number and a bracket against the saved line

efforts sofar

Expand|Select|Wrap|Line Numbers
  1. #!/bin/bash
  2. echo "filename"
  3. read myvar
  4. grep $USER $myvar > results.txt
  5. nl results.txt
  6.  

2. Write a script that takes two arguments. The first being a line of text, the second being a file. The script should take the first argument and insert it into the middle (the middle line) of the file named in second argument.


thanks in advancefor any help
you are doing homework right. so what's wrong with your first question? what have you done so far with your second question?
Jul 8 '07 #4

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

4 posts views Thread by jobs | last post: by
2 posts views Thread by kj | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.