I would like to echo a list all in one line, TAB separated (like ls does with files in one folder)  for i in one two some_are_very_long_stuff b c; do echo $i; done   will print one line per word:  one two some_are_very_long_stuff b c   instead I would like to break it, like ls without options does:  mkdir /tmp/test cd /tmp/test for i in one two some_are_very_long_stuff b c z; do touch $i; done ls   will output  b  one                       two c  some_are_very_long_stuff  z
123669
How do I columnate any uncollumnated input like ls does?  ls is creating an optimized table with minimum width for each row, for example:  ls  2  dsao  file with space  with 5  e     g                wsdl-rubo-6cb0f1a9086e80c d  file   leading space   but if I feed output into column (for ex. each file on one line), it pads every row the same width, so it fits the screen width:  for i in *; do echo "$i"; done | column  2                               file with space                           5                               g                                         d                                leading space                            dsao                            with                                      e                               wsdl-rubo-6cb0f1a9086e80c                 file   (I use only the file list here to generate the same output as example, I am looking for such a solution to columnize other things in the end.)  How can I colunnize any output with a variable col-width?
123071
I have the following in a script  for server in ${servers[@]}; do     echo ${server}     ssh user@${server} "for i in /tmp/foo* ; do echo ${i}; done" done   But it doesn't work. Weird thing, I see $I amount of return lines. So if I have ten files, I see ten blank lines.
72476
My current best bet is:  for i in $(find . -name *.jpg); do echo $i; done   Problem: does not handle spaces in filenames.   Note: I would also love a graphical way of doing this, such as the "tree" command.
56187
I've got multiple-line text files of (sometimes) tab-delimited data.  I'd like to output the file so I can glance over it - so I'd like to only see the first 80 characters of each line (I designed the text file to put the important stuff first on each line).  I'd thought I could use cat to read each line of the file, and send each line to the next command in a pipe:  cat tabfile | cut -c -80   But that seemed broken.  I tried monkeying around, and grep appeared to work - but then I found out that, no it didn't (not every line in the file had 80+ characters) - it appears tabs are counted as single characters by cut.  I tried:  cat tabfile | tr \t \040 | cut -c -80   Even though that would mangle my data a bit, by eliminating the white-space readability.  But that didn't work.  Neither did:  cat tabfile | tr \011 \040 | cut -c -80   Maybe I'm using tr wrong?  I've had trouble with tr before, wanting to remove multiple spaces (appears the version of tr that I have access to on this machine has an -s option for squeezing down multiple characters - I may need to play with it more)  I'm sure if I messed around I could use perl, awk or sed, or something to do this.  However, I'd like a solution that uses (POSIX?) regular commands, so that it's as portable as possible.  If I do end up using tr, I'd probably eventually try turning tabs into characters, maybe do a calculation, cut on the calculation, and then turn those characters back into tabs for the output.  It doesn't need to be a single line / entered directly on the command line - a script is fine.    More info on tab-files:  I use tab to break fields, because someday I may want to import data into some other program.  So I tend to have only one tab between pieces of content.  But I also use tabs to align things with vertical columns, to aid in readability when looking at the plain text file.  Which means for some pieces of text I pad the end of the content with spaces until I get to where the tab will work in lining up the next field with the ones above and below it.   DarkTurquoise           #00CED1         Seas, Skies, Rowboats   Nature MediumSpringGreen       #00FA9A         Useful for trees        Magic   Lime                    #00FF00         Only for use on spring chickens and fru$
21256
I'd like to find a Windows batch counterpart to Bash's $@ that holds a list of all arguments passed into a script.   Or I have to bother with shift?
62986
I have tried to get the 2 files output in a single file.  I have tried below command:  cat file1 file2   but here file2 data is appending to file1.  What I need is file1 1st line followed by file2 first line, and file1 second line followed by file2 second line etc.  Can anybody tell me how to do this in a simple way?
37919
I want to print the odd-numbered and even-numbered lines from files.  I found this shell script which makes use of echo.  #!/bin/bash # Write a shell script that, given a file name as the argument will write # the even numbered line to a file with name evenfile and odd numbered lines # in a text file called oddfile. # ------------------------------------------------------------------------- # Copyright (c) 2001 nixCraft project &lt;http://cyberciti.biz/fb/&gt; # This script is licensed under GNU GPL version 2.0 or above # ------------------------------------------------------------------------- # This script is part of nixCraft shell script collection (NSSC) # Visit http://bash.cyberciti.biz/ for more information. # -------------------------------------------------------------------------  file=$1 counter=0  eout="evenfile.$$" # even file name oout="oddfile.$$" # odd file name  if [ $# -eq 0 ] then     echo "$(basename $0) file"     exit 1 fi  if [ ! -f $file ] then     echo "$file not a file"     exit 2 fi  while read line do     # find out odd or even line number     isEvenNo=$( expr $counter % 2 )      if [ $isEvenNo -ne 0 ]     then         # even match         echo $line &gt;&gt; $eout     else         # odd match         echo $line &gt;&gt; $oout     fi     # increase counter by 1     (( counter ++ )) done &lt; $file echo "Even file - $eout" echo "Odd file - $oout"   But isn't there a way to do it in one line?  Yes, use awk, I read.  Even-numbered lines:  awk 'NR % 2' filename   odd-numbered lines:  awk 'NR % 2 == 1' filename   But it doesn't work for me. Both produce the same output, according to diff. When compared to the original file, they are both indeed half as long, and they both contain the odd-numbered lines. Am I doing something wrong?
34971
I would like to cat file, but with limit to max length to each line. For example I a have file with 10 lines each have 10000 characters and I would like to print first 100 characters from each line. Is something like that possible with cat or some alternative? thx.
29907
I was trying to write a shell script that will take a directory path d as an argument and recursively print a depth indented list of all files and directories in d. However, the argument d is optional and if no argument is given, a depth indented list of all files and directories​ ​in​ ​the​ ​current​ ​ directory​ will​ ​be printed. Here is my code: # the method for tree  myspace=&quot;&quot; spaceCount=0 tree(){        cd &quot;$1&quot;   for i in *; do     if [ -d &quot;$i&quot; ]; then       echo -n &quot;|&quot;          for (( j=0;j&lt;spaceCount;j++ ))        do          echo -n &quot;$myspace&quot;         done       echo &quot;--$i&quot;       spaceCount=$((spaceCount+1))        myspace=&quot;  |&quot;       tree &quot;$i&quot;     else       echo -n &quot;|&quot;       for (( j=0;j&lt;spaceCount;j++ ))        do          echo -n &quot;$myspace&quot;         done       echo &quot;--$i&quot;     fi   done   cd ../   spaceCount=$((spaceCount-1)) }   if [ &quot;$1&quot; != &quot;&quot; ]; then   file=&quot;$1&quot; fi echo &quot;.$file&quot; tree &quot;$file&quot;  But when a folder is empty, it's printing a star like this: How can I solve the problem?
88182
sed 's/[long1][long2]/[long3][long4]/' file.txt   I would like to split this command onto multiple lines - f.x. something like this:  sed 's/     [long1]     [long2]   /     [long3]     [long4]   /' file.txt   Using \ or separating strings didn't work.
27970
Let's say I write up a bunch of rows and decide I want to make it a list:  Item 1 Another Item Something Else   When I mark each line and click the "List" button (doesn't matter which one), the Editor takes all three rows and makes one list item out of them, ignoring the line-breaks.  The output will simply be:  - Item 1 Another Item Something Else   It would be far more useful and less buggy if it would instead create one list item for each line:  - Item 1 - Another Item - Something Else
19447
I want to execute a command, have the output of that command get gzip'd on the fly, and also echo/tee out the output of that command. i.e., something like: echo &quot;hey hey, we're the monkees&quot; | gzip --stdout &gt; my_log.gz  Except when the line executes, I want to see this on standard out: hey hey, we're the monkees
110061
To output all lines into a file /tmp/ps.txt  $ ps -e &gt;/tmp/ps.txt       To count it with wc -l  $ wc -l /tmp/ps.txt 172   To count it without exporting a file.  $ ps -e | wc -l 173   Why ps -e | wc -l  get one more line?  I don't think  for my question.  $ echo "test" | wc -l 1   Please try it in your terminal, it would yield 2 as .
26157
I've a file named addresses.txt :  address1@domain.com address2@domain.com address3@domain.com   I'd like to echo "address1@domain.com.html" using for loop. Here's what I did :  cat addresses.txt | while read address do echo "${address}.html" done   Here's the result :  .htmlss1@domain.com .htmlss2@domain.com .htmlss3@domain.com   Same result if I add a space between the variable and ".html"  What am I miss ?  Thanks
124182
I want to list all the files, in directory I am currently in, with for example &quot;a&quot; in their name. I know that the first part of the command would be ls -l, but i do not know how to finish it.
35787
Say I have this file:  hello world hello world   This program  #!/bin/bash  for i in $(cat $1); do     echo "tester: $i" done   outputs  tester: hello tester: world tester: hello tester: world   I'd like to have the for iterate over each line individually ignoring whitespaces though, i.e. the last two lines should be replaced by  tester: hello world   Using quotes for i in "$(cat $1)"; results in i being assigned the whole file at once. What should I change?
33101
How do I echo one or more tab characters using a bash script? When I run this code  res='       'x # res = "\t\tx" echo '['$res']' # expect [\t\tx]   I get this  res=[ x] # that is [&lt;space&gt;x]