I have a text file written in the following way :
/home/walter197/file_created.txt
/home/walter197/myfile1
/home/walter197/new.txt
/home/walter197/sdl.tar.gz
/home/walter197/sys_info.html
/home/walter197/test2.sh
I wrote the following shell script to read each line of the file text , cut the fourth column (which is the last column ) and write it to a new file:
#!/bin/bash
path="/home/walter197/info.txt"
new_file="/home/walter197/new_info.txt"
while IFS= read -r line
do
cut -d "/" -f 4 "$line" | cat $new_file
done < "$path"
exit
When i execute cat new_file.txt
I got horrible weird texts .
So how can i fix the script so i can get the following in the new file:
file_created.txt
myfile1
new.txt
sdl.tar.gz
sus_info.html
test2.sh
cut -d/ -f4 < "$path" > "$new_file"
orcut -d/ -f4 "$path" > "$new_file"