User Tools

Site Tools


docs:tips_n_tricks:shellscripting:shellscripting.html

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
docs:tips_n_tricks:shellscripting:shellscripting.html [08.04.2024 00:19 CEST] – [Colour diff output word-by-word] peterdocs:tips_n_tricks:shellscripting:shellscripting.html [08.04.2024 00:24 CEST] (current) – [Read output of command without pipe] peter
Line 322: Line 322:
 done done
 </code> </code>
 +
 +===== Running pipes in bash shellscripts in same shell environment  =====
 +This works only for one pipe or the last command piped to in a sequence
 +
 +<code bash read_ls_lines.sh [highlight_lines_extra="3"]>
 +#!/bin/bash
 +
 +shopt -s lastpipe
 +
 +datas=()
 +# touch "Mal was mit Lücken"
 +ls -a1 | while read data
 +do
 +  datas=("${datas[@]}" "$data")
 +done
 +
 +i=1
 +for line in "${datas[@]}"
 +do
 +  printf "%d: %s\n" "$((i++))" "$line"
 +done
 +</code>
 + 
  
  
docs/tips_n_tricks/shellscripting/shellscripting.html.txt · Last modified: 08.04.2024 00:24 CEST by peter

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki