Sponsored Content
Top Forums Shell Programming and Scripting comma separated string manipulation Post 302286879 by saharookiedba on Thursday 12th of February 2009 07:47:53 AM
Old 02-12-2009
comma separated string manipulation

hi,
i have a script where i am accepting a comma separated string from the user, i have to separated those strings on the basis of comma and store it in variables..

below is the script

Code:
 
#!/bin/ksh
clear
echo "Enter the strings seperated by commas :- \c "
read strn
echo $strn
count=`echo $strn | awk -F, {'print NF'}`
echo $count
i=1
while [ i -le count ]
do
 str${i}=`echo $strn | cut -d, -f${i}`
# $echo $str${i}
 i=`expr $i + 1`
done

output:-

Code:
 
Enter the strings seperated by commas :- a,b
a,b
2
./string_seprate.sh[12]: str1=a:  not found
./string_seprate.sh[12]: str2=b:  not found

i am not able to understand even when str1=a is being allocated, it is throwing this error...
please help me out....
 

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Need comma separated processing

I have a file like this OUTLN OPEN Y SCOTT OPEN N USER4 OPEN Y DBSNMP EXPIRED & LOCKED N ... (4 Replies)
Discussion started by: ilugopal
4 Replies

2. Shell Programming and Scripting

Inserting string in between field in comma separated file

Hello Mates, I have one txt file having commo seperated values. I have to insert string "FALSE" in 2nd field from the end. E.G SE18 6RN,,,,5439070,1786840,,1000002148671600,123434 Out put should be: SE18 6RN,,,,5439070,1786840,FALSE,1000002148671600,123434 Can some one help me to... (8 Replies)
Discussion started by: krsnadasa
8 Replies

3. Shell Programming and Scripting

Comma separated file

Hi all, I have the following files types: FileA: 100, 23, 33, FileB: 22, 45, 78, and i want to make File C: 100,22 23,45 33,78 any nice suggestions for making it easy. (3 Replies)
Discussion started by: hen1610
3 Replies

4. Shell Programming and Scripting

Need Help - comma inside double quote in comma separated csv,

Hello there, I have a comma separated csv , and all the text field is wrapped by double quote. Issue is some text field contain comma as well inside double quote. so it is difficult to process. Input in the csv file is , 1,234,"abc,12,gh","GH234TY",34 I need output like below,... (8 Replies)
Discussion started by: Uttam Maji
8 Replies

5. Shell Programming and Scripting

To agregate Comma separated values

Hi pls help me to get the code: i have a file in which content is : 2.01304E+11 2.01304E+11 ori 2 01:00 2.01304E+11 2.01304E+11 ori 2 01:02 2.01304E+11 2.01304E+11 ori 3 01:02 2.01304E+11 2.01304E+11 ori 3 ... (7 Replies)
Discussion started by: Aditya.Gurgaon
7 Replies

6. UNIX for Dummies Questions & Answers

[solved] Comma separated values to space separated

Hi, I have a large number of files which are written as csv (comma-separated values). Does anyone know of simple sed/awk command do achieve this? Thanks! ---------- Post updated at 10:59 AM ---------- Previous update was at 10:54 AM ---------- Guess I asked this too soon. Found the... (0 Replies)
Discussion started by: lost.identity
0 Replies

7. Shell Programming and Scripting

Need comma separated output

Hi, I am having the file with server names & its corresponding process, i need your help how to convert into comma separated output between server & app #cat apps.txt Server1 oracle was Server2 http webadmin Server3 tsm db2 My requirement is like below. Server1,oracle/was... (5 Replies)
Discussion started by: ksgnathan
5 Replies

8. Shell Programming and Scripting

awk to parse comma separated field and removing comma in between number and double quotes

Hi Experts, Please support I have below data in file in comma seperated, but 4th column is containing comma in between numbers, bcz of which when i tried to parse the file the column 6th value(5049641141) is being removed from the file and value(222.82) in column 5 becoming value of column6. ... (3 Replies)
Discussion started by: as7951
3 Replies

9. UNIX for Beginners Questions & Answers

How to extract fields from a CSV i.e comma separated where some of the fields having comma as value?

can anyone help me!!!! How to I parse the CSV file file name : abc.csv (csv file) The above file containing data like abv,sfs,,hju,',',jkk wff,fst,,rgr,',',rgr ere,edf,erg,',',rgr,rgr I have a requirement like i have to extract different field and assign them into different... (4 Replies)
Discussion started by: J.Jena
4 Replies
PERF-TRACE(1)							    perf Manual 						     PERF-TRACE(1)

NAME
perf-trace - strace inspired tool SYNOPSIS
perf trace DESCRIPTION
This command will show the events associated with the target, initially syscalls, but other system events like pagefaults, task lifetime events, scheduling events, etc. Initially this is a live mode only tool, but eventually will work with perf.data files like the other tools, allowing a detached record from analysis phases. OPTIONS
-a, --all-cpus System-wide collection from all CPUs. -e, --expr List of events to show, currently only syscall names. Prefixing with ! shows all syscalls but the ones specified. You may need to escape it. -o, --output= Output file name. -p, --pid= Record events on existing process ID (comma separated list). -t, --tid= Record events on existing thread ID (comma separated list). -u, --uid= Record events in threads owned by uid. Name or number. -v, --verbose= Verbosity level. -i, --no-inherit Child tasks do not inherit counters. -m, --mmap-pages= Number of mmap data pages. Must be a power of two. -C, --cpu Collect samples only on the list of CPUs provided. Multiple CPUs can be provided as a comma-separated list with no space: 0,1. Ranges of CPUs are specified with -: 0-2. In per-thread mode with inheritance mode on (default), Events are captured only when the thread executes on the designated CPUs. Default is to monitor all CPUs. --duration: Show only events that had a duration greater than N.M ms. --sched: Accrue thread runtime and provide a summary at the end of the session. -i --input Process events from a given perf data file. SEE ALSO
perf-record(1), perf-script(1) perf 06/30/2014 PERF-TRACE(1)
All times are GMT -4. The time now is 06:16 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy