473,387 Members | 1,485 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

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 2311
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

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

Similar topics

3
by: warhero721 | last post by:
HI. First i like to point out i suck at programing. All i realy whant to know is how do i git my site orginized.I whant to know how to do somthing like this Chatroom fourm sighn up event...
4
by: jobs | last post by:
Three noob questions. Please help. 1. Is there a way to have arguments on subroutine that are optional? 2. Say I need to convert datetime to string..in this format : 2006-09-07...
1
by: dellernet | last post by:
hello i had a website designed i believe in asp( not sure what kind) and a database in access that is linked to the site i have both the site and database. the trouble is i have no idea how to...
5
by: Hydrogenfussion | last post by:
Hello and thank you for reading this. I have just started to learn C++ from www.cprogramming.com,its a great site! But i do not understand some of the terms. I am using Dev-C++. Can you tell me...
2
by: sparks | last post by:
I have been programming access databases for 8 years. Well today I find out that I need to know SQL. HUH LOL well I don't have a clue as to how people even enter data into a sql database or...
4
by: Eyes Of Madness | last post by:
i am a student working on a project for a python class. i am trying to take one line of a text file at a time and put it into a temp set, then take that temp set and make it a dictionary. then go...
2
by: kj | last post by:
I'm a Python noob, and haven't yet figured out my way around the Python documentation. For example, suppose I learn about some great module foo.bar.baz, and when I run the python interpreter and...
4
by: Arch Stanton | last post by:
I'm trying to bind data in a dataset (obtained from an Access DB) to a listbox in ASP.net. I know my dataset is being created properly because it displays fine in a datagrid, but I can't get it to...
4
by: larry | last post by:
Ok I'm a Python noob, been doing OK so far, working on a data conversion program and want to create some character image files from an 8-bit ROM file. Creating the image I've got down, I open...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.