grep $USER xx >> filenorman.thai
i used the above command to gain a searched list for a user and put it into a file called filenorman.thai, the following is a bit of its contents...
USER=norman.thai
MAIL=/var/spool/mail/norman.thai
PWD=/home/norman.thai
HOME=/home/norman.thai My question is, how do i add the corresponding line number as well as a bracket to make the text look like this:-
1)USER=norman.thai
2)MAIL=/var/spool/mail/norman.thai
3)PWD=/home/norman.thai
4)HOME=/home/norman.thai
8 3057 - awk '$0=++c")"$0' filenorman.thai>_tmp&&mv _tmp filenorman.thai
- awk '$0=++c")"$0' filenorman.thai>_tmp&&mv _tmp filenorman.thai
Is there a method without awk cos i'm learning from the basics and i've used tmp files before but i want a way without using a tmp file. Thanks
It uses temporary file implicitly though ... - (rm file&&nl -s\) -w1>file)<file
It uses temporary file implicitly though ... - (rm file&&nl -s\) -w1>file)<file
i was told to look into loops. I'm new tho i'll have a crack at what you put in.
i was told to look into loops.[...]
I'd search google for shell scripting tutorial ...
I'd search google for shell scripting tutorial ...
Hey thanks for your time, both codes you provided for me work, i vaguely understand the last one...i just don't understand why my tutorials would ask me to look at loops.
If you have any time could you explain the nl -s\ command and w1 in your coding - (rm file&&nl -s\) -w1>file)<file
Thanks again you have been helpful
Sure,
man nl says:
nl - number lines of files
[...]
-s, --number-separator=STRING
add STRING after (possible) line number
[...]
-w, --number-width=NUMBER
use NUMBER columns for line numbers
The -s option let you specify the character after the number:
")" in our case, we need to escape it,
because it's special for the shell, the -w option let you specify
the number of columns for the line numbers, try the command
without it to see the difference.
Sure,
man nl says:
nl - number lines of files
[...]
-s, --number-separator=STRING
add STRING after (possible) line number
[...]
-w, --number-width=NUMBER
use NUMBER columns for line numbers
The -s option let you specify the character after the number:
")" in our case, we need to escape it,
because it's special for the shell, the -w option let you specify
the number of columns for the line numbers, try the command
without it to see the difference.
Ahhh thanks very much, much appreciated!
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Sue |
last post by:
On code-behind page:
(attributes set programatically for each of these elements)
linkbutton added to tablecell
textbox added to tablecell
tablecells added to tablerow
tablerow added to table...
|
by: Volker Hetzer |
last post by:
Hi!
I've done lots of programming for CAD, which was basically C/C++ and tcl/tk.
Now, we are thinking about introducing more web based tools, programming
them ourselves and right now the toolchain...
|
by: kamkwokho |
last post by:
Could any answer following questions as many as you can.
ii) Write a C shell script convertmin which will read in a number, thought
of as representing minutes, and print out the number of...
|
by: Jim Heavey |
last post by:
Trying to figure out the technique which should be used
to add rows to a datagrid. I am thinking that I would
want an "Add" button on the footer, but I am not quite
sure how to do that. Is that...
|
by: Ankit Aneja |
last post by:
I have a strange situation and I have no idea how to solve this.
Its a Recruitment Search Page,in the Admin Page, for every button click
event the Admin Person has to create a checkbox on the users...
|
by: Franz Steinhaeusler |
last post by:
Hello, I need a regularexpression, which trims trailing whitespaces.
While with unix line endings, it works;
but not with Window (Dos) CRLF's:
>>> import re
>>> retrailingwhitespace =...
|
by: Osoccer |
last post by:
...to a different folder and in the relocated file concatenates all of the lines in one long string with a space between each line element. Here is a fuller statement of the problem:
I need a...
|
by: mazwolfe |
last post by:
Someone recently asked about reading lines. I had this code written
some time ago (part of a BASIC-style interpreter based on H. Shildts
in Art of C) to read a file with the lines ended in any...
|
by: Hongyu |
last post by:
Dear all:
I am trying to write to a file with full directory name and file name
specified (./outdir/mytestout.txt where . is the current directory)
in
C programming language and under Unix, but...
|
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...
|
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...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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,...
|
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...
|
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,...
|
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: 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...
|
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,...
| |