GC 13
  • Member for 9 years, 1 month
  • Last seen this week
  • Chicago, IL, United States
GNU screen status bar - how to make it display shell session names?
Accepted answer
29 votes

Edit or create (if not present) /etc/screenrc or (~/.screenrc) and add below code autodetach on startup_message off hardstatus alwayslastline shelltitle 'bash' hardstatus string '%{gk}[%{wk}%?%-...

View answer
AWK compare to produce desired merged output
2 votes

$ awk -F, -v OFS=, 'NR==FNR{a[$1]=$2; next} {print $2,a[$4]}' data1.csv data2.csv #Output [GC@GC awk]$ ls data1.csv data2.csv [GC@GC awk]$ awk -F, -v OFS=, 'NR==FNR{a[$1]=$2; next} {print $2,a[$4]}'...

View answer
Remove lines from command output
Accepted answer
1 votes

Using grep, works best in this case: 1) yarn top | grep -A20 APPLICATIONID A - Print data after matching string 20 - number of lines to be printed after (A) matching string [gc13@oc1245342277 sh]$...

View answer
How to open the first 10 files in a folder starting with a certain letter or number?
1 votes

Using a loop and catching user input, it can be achieved: #!/bin/bash # Store all list of files you want with extension png arr=(./*.png) for ((i=0; i<${#arr[@]};)) do # -s: do not echo input ...

View answer
How do i pass $1 to sed?
1 votes

I am not quite sure why it is failing for you when same script works as expected for me. sed.sh 1 #!/bin/bash 2 directory=$1 3 echo $directory 4 LC_CTYPE=C 5 sed -i.clean -f uncap-html.sed ...

View answer
Reading first N lines from each member of a zip archive
0 votes

Using unzip and grep: (Note: This answer takes reference of @RomanPerekhrest's answer and a post here) bash-3.2$ unzip -l ten.zip Archive: ten.zip Length Date Time Name --------- -----...

View answer
How can I match a string when not preceded by a digit using awk?
0 votes

Using grep: grep [^0-9][3][N] file v - to show those that don't match / invert match [0-9][3][N] - pattern to find 3N with a positive integer preceding.

View answer
Sed command usage without defining variables in shell script
Accepted answer
0 votes

Used character matching in your sed command: Character Class - [:digit:] = Numeric digits [0-9] sed "s/fdl_ppe_01_[0-9][0-9]_repos_svc/$target_repo/g" $1 > $1_changed $1_changed will give you ...

View answer
How can we revisit screen command?
0 votes

screen -ls or screen -list will generate you the list of screen sockets available currently. screen -x <socket_name> attach an existing screen session screen -Dr <socket_name> reattach ...

View answer
Count rows with specific integer in a column
0 votes

Following execution will lead you to your required output. 1) awk '{print $5}' 4.txt | grep -c 4 2) awk '{print $5}' 4.txt | grep -c 5 3) awk '{print $5}' 4.txt | sort | uniq -c ...

View answer