LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 03-06-2016, 10:45 AM   #16
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,623

Rep: Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964

Quote:
Originally Posted by postcd View Post
Please anyone else know the solution for this (see initial mesaage)? I cant believe it can be so difficult to come with simple, clever solution.
You've been handed:
  • A tip to look at xargs
  • A sample script which will work with a SMALL amount of thought and effort on your part
  • A tip to look at string replacement/eval command (with a sample script)
  • Links to bash scripting tutorials
...and you STILL can't/won't/aren't showing us anything YOU, personally, have done to make this happen. You STILL haven't shown us your sample input data, or what you're after for output data exactly...despite being asked for these things numerous times. This is the same behavior you show in most of your other threads.

This seems to dovetail nicely with your previous comment of "Im not looking to waste hours of time reading some technical data to get answer to my question." We WILL NOT write your script for you. Show effort of your own.
 
1 members found this post helpful.
Old 03-06-2016, 10:53 AM   #17
postcd
Member
 
Registered: Oct 2013
Posts: 527

Original Poster
Rep: Reputation: Disabled
That script was not helpfull alas.
 
Old 03-06-2016, 11:02 AM   #18
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,680

Rep: Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894
Which script?
Did you look at the link I posted?
 
Old 03-06-2016, 11:08 AM   #19
postcd
Member
 
Registered: Oct 2013
Posts: 527

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by michaelk View Post
Which script?
Did you look at the link I posted?
Yes, this seems related

stringZ=abcABC123ABCabc
echo ${stringZ//abc/xyz}

But not sure how i can use it in my case. I already tried it, but it do not replace phrasse "$ip" by IP. I used something like:
echo ${url//1.1.1.1/$ip}
and
echo ${url//$ip/1.1.1.1}
but no change in variable

Last edited by postcd; 03-06-2016 at 11:17 AM.
 
Old 03-06-2016, 11:13 AM   #20
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,804

Rep: Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306
Quote:
Originally Posted by postcd View Post
Please anyone else know the solution for this (see initial mesaage)? I cant believe it can be so difficult to come with simple, clever solution.
Looks like it is definitely difficult. In general it is something like "communication error". You do not understand the solution given and the others do not really understand what is your problem.
I have only one comment to this (see LQ rules)
"That script was not helpfull alas." is not an acceptable answer.
"your copy paste "solutions" that do not fits my case. That is why im asking for other people oppinion" is not an answer too.
If you want to improve the quality of this communication (and obviously it is you who need a solution) you need to give some information about: what was wrong with that? Otherwise others will not be able to help you, because they (even me) have no idea how to give a better tip...
 
1 members found this post helpful.
Old 03-06-2016, 11:18 AM   #21
postcd
Member
 
Registered: Oct 2013
Posts: 527

Original Poster
Rep: Reputation: Disabled
pan64: i dont understand anything on one single script that was provided in this thread. Not sure how it can work in my case.
 
Old 03-06-2016, 11:26 AM   #22
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,804

Rep: Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306
in that case ask how does this or that work, even line by line. Probably you will be able to modify it to fit your needs. But "repeating does not work" will not help
 
Old 03-06-2016, 11:31 AM   #23
postcd
Member
 
Registered: Oct 2013
Posts: 527

Original Poster
Rep: Reputation: Disabled
ok, then im asking for line by line explanation, if there is not any more simplistic way to achive what i want. i never thought it can be that difficult, wanted to learn some simple way.
 
Old 03-06-2016, 11:31 AM   #24
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,623

Rep: Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964
Quote:
Originally Posted by postcd View Post
pan64: i dont understand anything on one single script that was provided in this thread. Not sure how it can work in my case.
You do this by doing something you have flat out said you don't want to do: READ AND LEARN. Again, you STILL, despite being asked many times, do not provide sample input data, sample output data, or most importantly ANYTHING THAT YOU, PERSONALLY HAVE ACTUALLY DONE OR TRIED. You are expecting people to hand you a script that 'meets your case', without YOU having to do anything. How many times, over the past three years, have you done exactly this?

Sorry, the scripts provided WILL work, if you put any effort into them. If you actually posted something like "I modified the script in post #xxx, and gave it this input, but got this result, and I'm confused", you'd get help. Saying "it doesn't work" tells us nothing.

And looking at the link michaelk gave you (after suggesting you look at it, they also had to look up a link for you), the sample script tells you exactly what you need to do...but you didn't do it. You're not following the syntax that's very clearly laid out in that document. And whether you like it or not, the FIRST REPLY (post #2), will work perfectly for you. It not only shows you how to read a file into an array, but how to process that array into variables (which is EXACTLY WHAT YOU WANT), then perform operations on that array...such as print them out, or do whatever you want with them.
 
1 members found this post helpful.
Old 03-06-2016, 11:33 AM   #25
postcd
Member
 
Registered: Oct 2013
Posts: 527

Original Poster
Rep: Reputation: Disabled
post reported & ignored, please be ontopic.
 
Old 03-06-2016, 11:44 AM   #26
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,623

Rep: Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964Reputation: 7964
Quote:
Originally Posted by postcd View Post
post reported & ignored, please be ontopic.
It was on topic, and as you've been told before, report whatever you want. AGAIN:
  • You are asked for sample input data. You have not provided it.
  • You are asked for sample output data. You have not provided it.
  • You are asked for examples of what YOU, PERSONALLY have done. You have not provided it
  • You say NOTHING about the problems you're having with the script(s)/example(s)
  • You keep asking for something to 'meet your case', yet show no effort of your own
NONE of these things are in keeping with LQ Rules or Question Guidelines, period.
Quote:
Originally Posted by postcd
ok, then im asking for line by line explanation, if there is not any more simplistic way to achive what i want. i never thought it can be that difficult, wanted to learn some simple way.
It isn't difficult...would take me about 5 minutes to write such a script, and any others that have replied to you could do it in about the same time. That is because instead of whining about "im newbie" (after three years), they actually learned and read the scripting tutorials, wrote scripts, and LEARNED. Asking for "line by line explanation" is the first sign of effort you have actually shown in any of your posts.
Code:
saveIFS="$IFS"  IFS defines what separates the fields. In this case, a newline. Replace with whatever is your separator
IFS=$'\n'
array=($(<file)) Open your input file, and read it all into the array. This would assume you have a file with foo and bar in it
IFS="$saveIFS"  Only needed if something in the loop depends on IFS
echo ${array[0]}    Array element 1 (starts at zero), output: EXAMPLEfoo 
echo ${array[1]}    Array element 2 (second after separator) output: EXAMPLEbar 
for i in "${array[@]}"; do echo "$i"; done    iterate over the array, until you're done reading the input file
So instead of echoing $i back out, put it into your output string wherever you want.

AGAIN...try reading the bash scripting tutorials.
 
1 members found this post helpful.
Old 03-06-2016, 11:51 AM   #27
postcd
Member
 
Registered: Oct 2013
Posts: 527

Original Poster
Rep: Reputation: Disabled
post not read and ignored as it do not provide any helpfull solution
 
Old 03-06-2016, 12:35 PM   #28
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,804

Rep: Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306
what do you think, what will be really helpful - for you?
 
1 members found this post helpful.
Old 03-06-2016, 12:40 PM   #29
postcd
Member
 
Registered: Oct 2013
Posts: 527

Original Poster
Rep: Reputation: Disabled
you do not know what is helpfull when you ask the question?
an answer that can help you solve the issue.
prefferably example with comment on how that works. are you that stupid not to understand this. I hope i explained enough. And we can stop offtopic and time waste in this thread. If anyone of you do not wish to provide what i said, please be so kind and give me a favor to stay away from commenting in my topics and wasting everyones time.

Last edited by postcd; 03-06-2016 at 12:50 PM.
 
Old 03-06-2016, 12:50 PM   #30
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,804

Rep: Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306
I'm afraid here, at LQ everyone is so stupid, they cannot understand you. Thanks for your valuable input.
 
1 members found this post helpful.
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] How to use variable to replace '&' ? 915086731 Linux - General 9 08-18-2011 02:30 AM
replace filename with variable Siljrath Programming 2 11-12-2009 12:40 AM
how to replace with variable using sed? babag Programming 4 09-17-2008 03:28 PM
Replace variable with user defined variable ce124 Programming 10 04-13-2007 09:29 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 05:56 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration