Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Add word/value at the beginning of each line in a file Post 302738313 by jason6247 on Friday 30th of November 2012 10:40:07 PM
Old 11-30-2012
Add word/value at the beginning of each line in a file

how to add value/word at the beginning of each line in a file ?

i have file number.txt and the output is below

1000
1001
1002
1003
1004

i want to add 000 at the beginning of each line, desire output is below
0001000
0001001
0001002
0001003
0001004
and so on

please advise how to do it, i been searching forum but with no luck

---------- Post updated at 10:40 PM ---------- Previous update was at 10:33 PM ----------

Quote:
Originally Posted by jason6247
how to add value/word at the beginning of each line in a file ?

i have file number.txt and the output is below

1000
1001
1002
1003
1004

i want to add 000 at the beginning of each line, desire output is below
0001000
0001001
0001002
0001003
0001004
and so on

please advise how to do it, i been searching forum but with no luck
i have tried command seq -f "%010g" first number last number
but seq can only format number until 6 digit long, it wont print output 0000100001 0000100002 instead it become 0000.5.+.09 something
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Add a word at the end of each line in a file

Hi I want to read a flat file and add a word/value at the end of each line in the file and store the output in a temporary file. How can i do this? Plz help me with this. Regards, Saurabh (6 Replies)
Discussion started by: bhalotias
6 Replies

2. Shell Programming and Scripting

Want to add a word in front a of each line of a file

Hi, Can anybody help me how to add a word in front of a line in a file.Actually it is bit tricky to add a word. i will give a sample for this: Input : 1110001 ABC DEF 1110001 EFG HIJ 1110001 KLM NOP 1110002 QRS RST 1110002 UVW XYZ Output: %HD% 1110001 ABC DEF %DT% 1110001 EFG HIJ... (4 Replies)
Discussion started by: apjneeraj
4 Replies

3. Shell Programming and Scripting

How to fetch rows based on line numbers or based on the beginning of a word?

I have a file which will have rows like shown below, ST*820*316054716 RMR*IV*11333331009*PO*40.31 REF*IV*22234441009*xsss471-2762 DTM*003*091016 ENT*000006 RMR*IV*2222234444*PO*239.91 REF*IV*1234445451009*LJhjlkhkj471-2762 </SPAN> DTM*003* 091016 RMR*IV*2223344441009*PO*40.31... (18 Replies)
Discussion started by: Muthuraj K
18 Replies

4. Linux

Add file's date at beginning of every line in file

How would I do that? /Rutger (6 Replies)
Discussion started by: rutgerblom
6 Replies

5. Shell Programming and Scripting

add a number to the beginning of every line

hey, i would like to add a line number to the beginning like so: red blue green yellow will be: 1=>red 2=>blue 3=>green 4=>yellowplease advise thank u. (5 Replies)
Discussion started by: boaz733
5 Replies

6. Windows & DOS: Issues & Discussions

Trying to add text to the beginning of each line

Well here goes: I tried to write a batch file that adds a specific fixed text to each line of an already existing text file. for the adding text infront of each line I tried this: for /F "delims=" %%j in (list.txt) do echo.STARTTEXT\%%j >> list.txt for adding text after each line I... (6 Replies)
Discussion started by: pasc
6 Replies

7. Shell Programming and Scripting

Add new line at beginning and end of a file

Hi, I have a specific requirement to add text at the beginning and end of a plain text file. I tried to use "sed" with '1i' and '$a' flags but these required two separate "sed" commands separated with "|". I am looking for some command/option to join these two in single command parameter. ... (6 Replies)
Discussion started by: bhupinder08
6 Replies

8. Shell Programming and Scripting

How to add one line in the beginning of the file?

Hi gurus, I need add one new line in the begining of current file. current file abc cde add xyz output file newline abc cde add xyz (6 Replies)
Discussion started by: ken6503
6 Replies

9. Shell Programming and Scripting

Add words in beginning , end after removing a word in a file

My file has the entries like below... /dev/sds /dev/sdak /dev/sdbc /dev/sdbu I want to make the file like below echo 1 > /sys/block/sds/device/rescan echo 1 > /sys/block/sdak/device/rescan echo 1 > /sys/block/sdbc/device/rescan echo 1 > /sys/block/sdbu/device/rescan (2 Replies)
Discussion started by: saravanapandi
2 Replies

10. Shell Programming and Scripting

Add the word "prefix" to beginning of line using sed

SUSE linux bash shell this works test -d /tmpp && echo "directory exists" || echo "directory doesn't exists" |sed -e "s/^/prefix /" prefix directory doesn't exists but why doesn't this work? test -d /tmp && echo "directory exists" || echo "directory doesn't exists" |sed -e... (3 Replies)
Discussion started by: snoman1
3 Replies
WTOC(1) 						      General Commands Manual							   WTOC(1)

NAME
wtoc - Convert a Wnn text-form dictionary (or dictionaries) into Canna text-form dictionaries SYNOPSIS
wtoc [-f hinshidata] [wnnjisho] [cannajisho] DESCRIPTION
wtoc converts a Wnn text-form dictionary file into Canna text-form dictionary file. If all dictionary files are omitted, the Wnn dictio- nary data is input through the standard input. In this case, the dictionary of the Japanes Input System is output from the standard out- put. If one dictionary file is specified, it will be regarded as a Wnn dictionary. At this time, Canna dictionary output to the standard output. OPTIONS
-f hinshidata The user can add new information about word-type correspondence between Wnn and Canna. The following word-type correspondence information must be described in the hinshidata file. Within one line, describe the Wnn word type name and the Canna word type while delimiting by a space(s) or tab. Wnn word type Canna word type Adverb #F04 EXAMPLE
% wtoc -f tsuikahinshi kihon.u kihon.t Inputs word-type correspondence information from tsuikahinshi, then converts Wnn text-form dictionary kihon.u into the Canna text-form dic- tionary before output. % wtoc special.u | lpr Converts Wnn text-form dictionary special.u into Canna text-form dictionary, then outputs the result to the line printer. SEE ALSO
ctow(1) WTOC(1)
All times are GMT -4. The time now is 03:26 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy