Created
June 26, 2025 05:00
-
-
Save huynhbaoan/c09ec4e9b2f7dc0b626bb3c6cba105cc to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
while IFS= read -r line; do | |
# Check if the line contains a tab | |
if [[ "$line" == *$'\t'* ]]; then | |
# Split the line by tabs into an array | |
IFS=$'\t' read -r -a cols <<< "$line" | |
# Only process if at least 4 columns exist | |
if [[ ${#cols[@]} -ge 4 ]]; then | |
# Grab column 4 | |
col4="${cols[3]}" | |
# Do the replacements using perl | |
col5=$(perl -pe 's/-private|-tooling|-v[0-9]+(secondary)?//g' <<< "$col4") | |
# Output original columns plus new column 5 | |
printf "%s\t%s\n" "$line" "$col5" | |
else | |
echo "$line" | |
fi | |
else | |
echo "$line" | |
fi | |
done < yourfile.tsv |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment