473,804 Members | 3,308 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Complete NOOB need help

1 New Member
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 2332
shahjapan
63 New Member
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 Recognized Expert Contributor
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 Recognized Expert Contributor
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
1594
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 donate serchengine
4
1216
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 23:00:00.000
1
1090
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 connect these two together so as it will work on a web server. i need to move both to another webserver as i am concerned about the company currently hosting it for me. i cannot afford to pay somebody to sort this for me at the moment so i need to try...
5
2092
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 where to go to understand C++ terms? TY When i said i was a noob i meant it. This is the ONLY thing i have written: #include <iostream> using namespace std;
2
1352
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 how to manipulate or retrieve data. Can someone please recommend a book to get me started? thank you very much for any and all help with this.
4
1185
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 through the next line so on and so forth. whenever i try to do that it takes the whole file and puts it into a set. im not really sure how to implement my above strategy. right now im just focusing on making everything go through set process. im not yet...
2
1042
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 type "import foo.bar.baz", lo and behold, it is already installed on our system, which means that (knowing that our system is pretty bare-bones as far as python goes) most likely foo.bar.baz is part of the standard python installation.
4
5115
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 display in a listbox. Here's what I'm trying: dgrDataGrid.DataSource = dstData.Tables("Manufacturer") lstMake.datasource = dstData.Tables("Manufacturer") Page.DataBind There is only one column in the dataset's table, and the datagrid
4
2109
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 the file and use TK to draw the images... but 1) It does not seem to end (running in IDLE), I have to kill the process to retry it seems tkinter does not close(?)
0
10571
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10326
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10317
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10075
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9143
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6851
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5651
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4295
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2990
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.