LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 12-16-2020, 12:07 AM   #16
stratos20vt
LQ Newbie
 
Registered: Dec 2020
Location: chania, crete, greece
Posts: 12

Original Poster
Rep: Reputation: Disabled

I tried it and it works, is there any other way without cat command?
I have searched in internet, in books and the problem is that everywhere
you can find what each command does, you can't find which command does the
procedure you want. everywhere they say that you can do it with cat command.
if it is a problem for you I won't ask again anything, but this is not
a way to encourage someone to get started with Linux. I am not a young student.
I am a physics teacher who is taking Linux lessons to enhance my teaching and knowledge.
 
Old 12-16-2020, 12:22 AM   #17
berndbausch
LQ Addict
 
Registered: Nov 2013
Location: Tokyo
Distribution: Mostly Ubuntu and Centos
Posts: 6,316

Rep: Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002
Quote:
Originally Posted by stratos20vt View Post
I tried it and it works, is there any other way without cat command?
echo -e "one\ntwo\nthree" works. Here are a few pointless alternatives:
Code:
python -c 'print "one\ntwo\nthree"'
sed 's/#/\n/g' <<< "one#two#three"
awk 'BEGIN {print "one"; print "two"; print "three"}' </dev/null
Perhaps the sed solution is interesting, because it highlights the <<< construct. I think it's a Bashism.

Perl should be capable of doing that as well, but it gives me ulcers. For a special bonus, implement this in Intercal.

How many solutions do you need?

EDIT:
Code:
date +"one%ntwo%nthree"
bc <<< 'print "one\ntwo\nthree\n"'
EDIT2
Code:
echo 'main(){printf("one\ntwo\nthree\n");}'>lines.c;make lines;./lines
I will stop here.

Last edited by berndbausch; 12-16-2020 at 12:32 AM.
 
2 members found this post helpful.
Old 12-16-2020, 12:24 AM   #18
stratos20vt
LQ Newbie
 
Registered: Dec 2020
Location: chania, crete, greece
Posts: 12

Original Poster
Rep: Reputation: Disabled
only linux without vi commands
 
Old 12-16-2020, 12:29 AM   #19
berndbausch
LQ Addict
 
Registered: Nov 2013
Location: Tokyo
Distribution: Mostly Ubuntu and Centos
Posts: 6,316

Rep: Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002
There are no vi commands in my solutions.
 
Old 12-16-2020, 08:32 AM   #20
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,615

Rep: Reputation: 7962Reputation: 7962Reputation: 7962Reputation: 7962Reputation: 7962Reputation: 7962Reputation: 7962Reputation: 7962Reputation: 7962Reputation: 7962Reputation: 7962
Quote:
Originally Posted by stratos20vt View Post
only linux without vi commands
Sorry, but are you just ignoring things?? This is **YOUR HOMEWORK**.

Instead of just telling us what you DO NOT want, why can't you show us any efforts of your own to do your work??
 
Old 12-16-2020, 08:46 AM   #21
stratos20vt
LQ Newbie
 
Registered: Dec 2020
Location: chania, crete, greece
Posts: 12

Original Poster
Rep: Reputation: Disabled
sorry to disturb you. I thought here was a place to find help and guidance.
i am not a child to take advices that this is my homework.
I found a real friend to help me love Linux.
You can delete the thread and goodbye...
 
Old 12-16-2020, 08:48 AM   #22
Turbocapitalist
LQ Guru
 
Registered: Apr 2005
Distribution: Linux Mint, Devuan, OpenBSD
Posts: 7,293
Blog Entries: 3

Rep: Reputation: 3718Reputation: 3718Reputation: 3718Reputation: 3718Reputation: 3718Reputation: 3718Reputation: 3718Reputation: 3718Reputation: 3718Reputation: 3718Reputation: 3718
Quote:
Originally Posted by stratos20vt View Post
only linux without vi commands
You can use ed or sed instead. As with vi there are whole books published on either. Your tech library might have one available for loan, sed at least, if it is a library of any caliber.

Anyway, about the assignment, as others have asked please show what you are trying and where you are stuck. Keep in mind that Linux is the kernel. Bash is the default shell on most distros and most of the programs you would invoke from Bash to solve your assignment are also from the GNU project others are from the BSD projects. Some, such as perl and python3, are not from GNU.
 
1 members found this post helpful.
Old 12-16-2020, 09:17 AM   #23
rtmistler
Moderator
 
Registered: Mar 2011
Location: USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu, Debian
Posts: 9,881
Blog Entries: 13

Rep: Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930
Quote:
Originally Posted by stratos20vt View Post
sorry to disturb you. I thought here was a place to find help and guidance.
i am not a child to take advices that this is my homework.
I found a real friend to help me love Linux.
You can delete the thread and goodbye...
stratos20vt,

Please understand that the premise of the LQ site is that we are here to "help", but also please understand that this is not intended for the questioner to obtain 100% free solutions, instead we're trying to get people to learn about Linux and thus help their selves more aptly for any future technical explorations they undertake. The old saying of "Give a person a fish, you've fed them a meal. Teach a person how to fish, and you've given them the talent to feed their self for a lifetime."

As part of our LQ Rules where some are fairly strong, there is one about homework, and here it is:
Quote:
Do not post homework assignments verbatim. We're happy to assist if you have specific questions or have hit a stumbling point, however. Let us know what you've already tried and what references you have used (including class notes, books, and searches) and we'll do our best to help. Keep in mind that your instructor might also be an LQ member.
The part where we're happy to assist and also the part about providing references, notes, searches, etc are the things people are reasonably asking your to update with. In general, people here are happy to provide suggestions, there are quite a few, and some interactive responses, which you have participated in for some of them.

Sorry but if you're unwilling to illustrate some of your efforts, it would seem that we are unable to help you further. But if you choose to share some more details about the things you have tried, versus continually providing blocking updates to suggestions, then perhaps you can get some assistance.

As an example, you certainly can provide a reply update which fully explains all of the allowances and restrictions that you are given as guidelines to complete your assignment, but you also should include what you've currently tried and how that worked, or didn't work, much like you showed examples of using echo, more, and I/O redirectors to files. It would be best for you to literally show what you presently have as your attempt and explain why it's not a final solution, along with the restrictions and allowances you must follow. Otherwise, this will continue to be a frustrating thread.
 
Old 12-16-2020, 09:25 AM   #24
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,615

Rep: Reputation: 7962Reputation: 7962Reputation: 7962Reputation: 7962Reputation: 7962Reputation: 7962Reputation: 7962Reputation: 7962Reputation: 7962Reputation: 7962Reputation: 7962
Quote:
Originally Posted by stratos20vt View Post
sorry to disturb you. I thought here was a place to find help and guidance.
i am not a child to take advices that this is my homework.
I found a real friend to help me love Linux.
You can delete the thread and goodbye...
Yes, this IS a place for help...however, you just keep repeating your homework question, and *TELLING* us what you won't accept. And you won't show us your efforts to actually do your 'exercise', and don't seem to want to research anything you're told about. You've been asked several times to show your efforts and have not.

The type of response you gave here has been seen many times in the past. Good luck in the future, because if you don't want to put effort into learning you most certainly won't have the knowledge or skills to do much of anything.
 
1 members found this post helpful.
Old 12-16-2020, 11:56 PM   #25
rnturn
Senior Member
 
Registered: Jan 2003
Location: Illinois (SW Chicago 'burbs)
Distribution: openSUSE, Raspbian, Slackware. Previous: MacOS, Red Hat, Coherent, Consensys SVR4.2, Tru64, Solaris
Posts: 2,799

Rep: Reputation: 550Reputation: 550Reputation: 550Reputation: 550Reputation: 550Reputation: 550
Quote:
Originally Posted by stratos20vt View Post
[snip]

I tried echo ''a'' \ ''b'' \ ''c'' > a.txt
but it makes one line.
I want to put a, b , c in different lines of the text.
So close... read the echo(1) manpage.
 
Old 12-17-2020, 03:04 AM   #26
MadeInGermany
Senior Member
 
Registered: Dec 2011
Location: Simplicity
Posts: 2,780

Rep: Reputation: 1198Reputation: 1198Reputation: 1198Reputation: 1198Reputation: 1198Reputation: 1198Reputation: 1198Reputation: 1198Reputation: 1198
The answer was given in post #6 (and post #10)

The answer to the other thread, that is NOT the same, is:

in zsh you can do
Code:
< file1 < file2 < file3 > newfile
and even
Code:
< file[1-3] > newfile
Code:
< file{1..3} > newfile
All other shell need cat that stands for concatenation
Code:
cat < file[1-3] > newfile
--
To answer questions that were not asked yet,
zsh can also produce multiple target files
Code:
< file{1..3} > newfile1 > newfile2
This feature is dangerous; you can easily destroy all your files with
Code:
>*

Last edited by MadeInGermany; 12-17-2020 at 03:08 AM.
 
1 members found this post helpful.
  


Reply

Tags
shell


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] converting multiple lines of text to single line of text with comma separting them cogiz Programming 25 10-11-2020 10:11 AM
[SOLVED] Joining Three Lines of Text into One Line with Delimiters Between the Original Lines tronayne Slackware 25 03-18-2016 09:46 AM
[SOLVED] Replace text lines identified by leading text in line within multiple files juergen852 Linux - Newbie 9 09-21-2014 04:54 PM
[SOLVED] CAT command | multiple lines to multiple lines udiubu Programming 11 10-28-2011 06:09 AM
Using cat readline within cat readline while loop demxkn66 Programming 5 12-16-2007 05:10 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 07:00 AM.

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