Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Add word/value at the beginning of each line in a file Post 302738363 by bdittmar on Saturday 1st of December 2012 07:48:10 AM
Old 12-01-2012
Have a look at this threat !

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

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



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
Have a look at :
https://www.unix.com/unix-dummies-que...es-column.html
Regards
 

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
ACHECK.1(1)						User Contributed Perl Documentation					       ACHECK.1(1)

NAME
acheck - Check common localization mistakes SYNOPSIS
acheck [OPTIONS] [INPUT_FILE] DESCRIPTION
This program parses a file checking for syntax rules and optionally asking Aspell for checking word spelling. It makes fix suggestions and outputs a corrected file accordingly adding review comments if requested. It tries to find the file type according to the extension or the first lines and loads rules accordingly. It displays lines when they are parse. When an error is found, a menu is displayed. Just press Enter if you don't want to change anything. If a choice suits you, enter the corre- sponding number. If you want to fix it but no choice is correct, enter a space, then you will be asked for a string to replace the high- lighted text. The script will replace the highlighted text with your choice and parse it again for new errors. Here are all the available commands: Enter, ignore. Ignore. Ctrl+L, redraw. Rewrite the last line, suggestions and hints. Space, edit. Edit the highlighted text. E, edit line. Edit the whole line. H, add hint. Add the displayed hint as review comment. Use this if you want the translator to see the corresponding warning or error but you have no correction. N, next line. Skip the rest of this line. X, exit and discard all changes. Quit without saving modifications, the script ask you for confirmation, you have to enter `yes' to exit otherwise parsing starts again at the current mistake. a, add in dictionary. Add the highlighted word to you personal dictionary, capitalized as it is. l, add lowercase in dictionary. Lowercase the highlighted word to add it to your personal dictionary. i, ignore word. Ignore the highlighted word, same as Enter. I, ignore all. Ignore the highlighted word and add it to your session dictionary. OPTIONS
Verbosity level: -q, --quiet quiet mode. -v verbose, start at level $Debug + 1, add more for more verbosity (see below). --verbose n set verbosity level to n (see below). Files: -i, --input input filename, can be '-' to read data from standard input. -o, --output output filename, can be '-' to write data to standard ouput. If no output filename is provided, input file is backed up with `bak_ext' extension and input filename is used. Spell check: -s, --spell check spelling with Aspell. -d language, --dict language use language dictionary for Aspell. -n, --nospell don't check spelling. Mode: -r, --review review mode, add comments on lines beginning with $Comment after parsed line. -t, --trans translator mode, don't add comments, just fix errors. others: --rules ruleset use ruleset rules set. --type filetype use filetype whatever the file type is. --dump Dump the rules to check and exit, use this for debugging purposes. -V, --version print version and exit. -h, --help print a short usage message and exit. Verbosity Level 0 quiet, normal only warnings and errors 1 debug names of subroutines 2 debug verbose names and arguments of subroutines 3 .. 5 debug very verbose output parsing and checking details SEE ALSO
acheck(5), acheck-rules(5) AUTHOR
Nicolas Bertolissio <bertol@debian.org> perl v5.8.4 2003-10-05 ACHECK.1(1)
All times are GMT -4. The time now is 03:56 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy