Converting a line into a list using awk or sed


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Converting a line into a list using awk or sed
# 8  
Old 12-20-2011
Using tr
Code:
echo "345 897 567 098 123" | tr \  \\\n

---------- Post updated at 06:42 AM ---------- Previous update was at 06:41 AM ----------

Already suggested by balajesuri Smilie
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Multiple line search, replace second line, using awk or sed

All, I appreciate any help you can offer here as this is well beyond my grasp of awk/sed... I have an input file similar to: &LOG &LOG Part: "@DB/TC10000021855/--F" &LOG &LOG &LOG Part: "@DB/TC10000021852/--F" &LOG Cloning_Action: RETAIN &LOG Part: "@DB/TCCP000010713/--A" &LOG &LOG... (5 Replies)
Discussion started by: KarmaPoliceT2
5 Replies

2. Shell Programming and Scripting

sed and awk giving error ./sample.sh: line 13: sed: command not found

Hi, I am running a script sample.sh in bash environment .In the script i am using sed and awk commands which when executed individually from terminal they are getting executed normally but when i give these sed and awk commands in the script it is giving the below errors :- ./sample.sh: line... (12 Replies)
Discussion started by: satishmallidi
12 Replies

3. Shell Programming and Scripting

Search from a line to end of list using sed

Dear Unix Experts :), Below is a small section of a large file with the following list: 1. Starts with string " interest" as the heading 2. Followed by a list of activities 3. Ends with a blank line before starting with another different list. E.g. Sporting interest football... (13 Replies)
Discussion started by: gjackson123
13 Replies

4. Shell Programming and Scripting

Scraping line - Using awk or sed

Hello, Can somone help with this command please? I have this output pattern in a file. I use a simple awk command to print each field separated by comma. For example I use this to get the first awk -F, "{ print $1 }" "ABC=abcdefg,CDF=mnqrst,GGG=hrvyess" issue: What I... (7 Replies)
Discussion started by: mnassiri
7 Replies

5. Shell Programming and Scripting

Get the list with sed or awk

#cat file aa bb cc dd ee 77 dd gg xx I want to get: when VAR="zzz D" get below out put (7 Replies)
Discussion started by: yanglei_fage
7 Replies

6. Shell Programming and Scripting

Converting txt file into CSV using awk or sed

Hello folks I have a txt file of information about journal articles from different fields. I need to convert this information into a format that is easier for computers to manipulate for some research that I'm doing on how articles are cited. The file has some header information and then details... (8 Replies)
Discussion started by: ksk
8 Replies

7. Shell Programming and Scripting

awk;sed appending line to previous line....

I know this has been asked before but I just can't parse the syntax as explained. I have a set of files that has user information spread out over two lines that I wish to merge into one: User1NameLast User1NameFirst User1Address E-Mail:User1email User2NameLast User2NameFirst User2Address... (11 Replies)
Discussion started by: walkerwheeler
11 Replies

8. Shell Programming and Scripting

Read logline line by line with awk/sed

Hello, I have a logfile which is in this format: 1211667249500#3265 1211667266687#2875 1211667270781#1828 Is there a way to read the logfile line by line every time I execute the code and put the two numbers in the line in two separate variables? Something like: 1211667249500#3265... (7 Replies)
Discussion started by: dejavu88
7 Replies

9. Shell Programming and Scripting

Number a list at end of line using 'sed'

Hi All I have a script which has produced a list, I have used 'sed' to number my list, but i want to list at end of line with the first line starting at zero (0) and brackets round it ie My List i want Hello (0) this (1) day (2) can (3) be (4) sed '/./=' filename | sed '/./N; s/\n/) /'... (5 Replies)
Discussion started by: chassis
5 Replies

10. UNIX for Dummies Questions & Answers

converting a list into a line

Hi, this is a pretty intersting problem, I would like to convert a list of words into a concatenated string of words with whitespace between each word. e.g file list :- hello how are you today convert into hello how are you today. What command would I use to do this? Thanks (2 Replies)
Discussion started by: zulander
2 Replies
Login or Register to Ask a Question
join(1) 							   User Commands							   join(1)

NAME
join - relational database operator SYNOPSIS
join [-a filenumber | -v filenumber] [-1 fieldnumber] [-2 fieldnumber] [-o list] [-e string] [-t char] file1 file2 join [-a filenumber] [-j fieldnumber] [-j1 fieldnumber] [-j2 fieldnumber] [-o list] [-e string] [-t char] file1 file2 DESCRIPTION
The join command forms, on the standard output, a join of the two relations specified by the lines of file1 and file2. There is one line in the output for each pair of lines in file1 and file2 that have identical join fields. The output line normally con- sists of the common field, then the rest of the line from file1, then the rest of the line from file2. This format can be changed by using the -o option (see below). The -a option can be used to add unmatched lines to the output. The -v option can be used to output only unmatched lines. The default input field separators are blank, tab, or new-line. In this case, multiple separators count as one field separator, and leading separators are ignored. The default output field separator is a blank. If the input files are not in the appropriate collating sequence, the results are unspecified. OPTIONS
Some of the options below use the argument filenumber. This argument should be a 1 or a 2 referring to either file1 or file2, respectively. -a filenumber In addition to the normal output, produce a line for each unpairable line in file filenumber, where filenumber is 1 or 2. If both -a 1 and -a 2 are specified, all unpairable lines will be output. -e string Replace empty output fields in the list selected by option -o with the string string. -j fieldnumber Equivalent to -1fieldnumber -2fieldnumber. -j1 fieldnumber Equivalent to -1fieldnumber. -j2 fieldnumber Equivalent to -2fieldnumber. Fields are numbered starting with 1. -o list Each output line includes the fields specified in list. Fields selected by list that do not appear in the input will be treated as empty output fields. (See the -e option.) Each element of which has the either the form filenum- ber.fieldnumber, or 0, which represents the join field. The common field is not printed unless specifically requested. -t char Use character char as a separator. Every appearance of char in a line is significant. The character char is used as the field separator for both input and output. With this option specified, the collating term should be the same as sort without the -b option. -v filenumber Instead of the default output, produce a line only for each unpairable line in filenumber, where filenumber is 1 or 2. If both -v 1 and -v 2 are specified, all unpairable lines will be output. -1 fieldnumber Join on the fieldnumberth field of file 1. Fields are decimal integers starting with 1. -2fieldnumber Join on the fieldnumberth field of file 2. Fields are decimal integers starting with 1. OPERANDS
The following operands are supported: file1 file2 A path name of a file to be joined. If either of the file1 or file2 operands is -, the standard input is used in its place. file1 and file2 must be sorted in increasing collating sequence as determined by LC_COLLATE on the fields on which they are to be joined, normally the first in each line (see sort(1)). USAGE
See largefile(5) for the description of the behavior of join when encountering files greater than or equal to 2 Gbyte (2**31 bytes). EXAMPLES
Example 1: Joining the password file and group file The following command line will join the password file and the group file, matching on the numeric group ID, and outputting the login name, the group name and the login directory. It is assumed that the files have been sorted in ASCII collating sequence on the group ID fields. example% join -j1 4-j2 3 -o 1.1 2.1 1.6 -t:/etc/passwd /etc/group Example 2: Using the -o option The -o 0 field essentially selects the union of the join fields. For example, given file phone: !Name Phone Number Don +1 123-456-7890 Hal +1 234-567-8901 Yasushi +2 345-678-9012 and file fax: !Name Fax Number Don +1 123-456-7899 Keith +1 456-789-0122 Yasushi +2 345-678-9011 where the large expanses of white space are meant to each represent a single tab character), the command: example% join -t"tab" -a 1 -a 2 -e '(unknown)' -o 0,1.2,2.2 phone fax would produce !Name Phone Number Fax Number Don +1 123-456-7890 +1 123-456-7899 Hal +1 234-567-8901 (unknown Keith (unknown) +1 456-789-012 Yasushi +2 345-678-9012 +2 345-678-9011 ENVIRONMENT VARIABLES
See environ(5) for descriptions of the following environment variables that affect the execution of join: LANG, LC_ALL, LC_CTYPE, LC_MES- SAGES, LC_COLLATE, and NLSPATH. EXIT STATUS
The following exit values are returned: 0 All input files were output successfully. >0 An error occurred. ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Availability |SUNWcsu | +-----------------------------+-----------------------------+ |CSI |Enabled | +-----------------------------+-----------------------------+ |Interface Stability |Standard | +-----------------------------+-----------------------------+ SEE ALSO
awk(1), comm(1), sort(1), uniq(1), attributes(5), environ(5), largefile(5), standards(5) NOTES
With default field separation, the collating sequence is that of sort -b; with -t, the sequence is that of a plain sort. The conventions of the join, sort, comm, uniq, and awk commands are wildly incongruous. SunOS 5.10 8 Feb 2000 join(1)