發表文章

目前顯示的是 11月 14, 2018的文章

How to get specific words by index in a line bash

圖片
up vote 0 down vote favorite I have a script that takes parameters such as: script.sh 1 3 I want to then go through a text file and print out the first and third words from each line. I have simply no idea how to do this. If anyone could help I'd really appreciate it... This is what I currently have: counter=0 wordcounter=0 param=$(echo "$3" | tr , " ") words() for word in $1; do for col in $param; do if [ $wordcounter -eq $col ]; then echo $word fi done done wordcounter=$((wordcounter + 1)) eachline() tr , " ") for word in $newline; do if [ $counter -gt 3 ]; then echo "$word" fi counter=$((counter + 1)) done if [ $counter -gt 0 ]; then words "$newline" fi counter=$((counter + 1)) while read line; do eachline $line done < company/employee.txt bash shell text share | improve this question edited Nov 10 at 12:57 asked Nov 10 at 12:11 Raph117 152 1 10

Germany

圖片
This article is about the country. For other uses, see Germany (disambiguation) and Deutschland (disambiguation). "Federal Republic of Germany" redirects here. For the country from 1949 to 1990, see West Germany. Federal parliamentary republic in central-western Europe Coordinates: 51°N 9°E  /  51°N 9°E  / 51; 9 Federal Republic of Germany Bundesrepublik Deutschland   (German) [a] Flag Coat of arms Motto:  " Einigkeit und Recht und Freiheit " (de facto) "Unity and Justice and Freedom" Anthem:  "Deutschlandlied" (third verse only) [b] "Song of Germany" Show globe Show map of Europe Location of   Germany    (dark green) – in Europe    (green & dark grey) – in the European Union    (green) Capital and largest city Berlin [c] 52°31′N 13°23′E  /  52.517°N 13.383°E  / 52.517; 13.383 Official language .mw-parser-output .noboldfont-weight:normal and national language German [1] [d] Ethnic groups (2016) [2] 70018080000000